210 lines
23 KiB
Plaintext
210 lines
23 KiB
Plaintext
fragment {
|
|
import package AgentPresentation;
|
|
import "presentation/model.qx";
|
|
|
|
type AgentSubmission = record {text:string;data:optional<string>;profile:optional<string>;response:optional<string>;sourceKind:string;sourceLabel:string;publication:optional<string>;createdAt:string;contexts:list<interface-ref<AgentContextSubject>>;related:optional<atom-ref<AgentRequestObject>>;retryOf:optional<atom-ref<AgentRequestObject>>;root:optional<atom-ref<AgentRequestObject>>;causalDepth:uint32;};
|
|
type AgentAdmission = record {accepted:bool;reason:optional<string>;thread:optional<atom-ref<AgentThreadObject>>;request:optional<atom-ref<AgentRequestObject>>;};
|
|
type DirectoryData = record {sequence:uint64;pending:uint32;ordinaryPending:uint32;notificationPending:uint32;profiles:string;availability:string;};
|
|
type ThreadData = record {title:string;kind:string;archived:bool;sequence:uint64;pending:uint32;nextItem:uint64;updatedAt:string;};
|
|
type AgentData = record {name:string;description:string;enabled:bool;settings:string;};
|
|
type RequestData = record {text:string;data:optional<string>;configuration:string;configurationDigest:string;responseKind:string;sequence:uint64;createdAt:string;sourceKind:string;sourceLabel:string;publication:optional<string>;causalDepth:uint32;interactive:bool;};
|
|
type RequestState = record {status:string;attempt:string;generation:uint32;reason:string;result:optional<string>;rawOutput:optional<string>;usage:optional<string>;startedAt:optional<string>;endedAt:optional<string>;cancelRequested:bool;retryCount:uint32;notificationPending:bool;};
|
|
type ItemData = record {key:string;kind:string;text:string;phase:string;activity:optional<string>;presentation:optional<string>;sequence:uint64;version:uint64;createdAt:string;updatedAt:string;control:optional<record {attempt:string;generation:uint32;status:string;reason:string;}>;};
|
|
type QuestionData = record {key:string;title:string;options:string;status:string;answer:optional<string>;createdAt:string;expiresAt:string;attempt:string;generation:uint32;};
|
|
|
|
import interface AgentWorkspace;
|
|
import interface AgentDirectory;
|
|
import interface Agent;
|
|
import interface AgentThread;
|
|
import interface AgentRequest;
|
|
import interface AgentItem;
|
|
import interface AgentQuestion;
|
|
import interface AgentContextSubject;
|
|
import interface EventStream;
|
|
import package AgentRuntime;
|
|
atom AgentDirectoryObject id "atom:org.quixos.agent:directory";
|
|
atom AgentObject id "atom:org.quixos.agent:agent";
|
|
atom AgentThreadObject id "atom:org.quixos.agent:thread";
|
|
atom AgentRequestObject id "atom:org.quixos.agent:request";
|
|
atom AgentItemObject id "atom:org.quixos.agent:item";
|
|
atom AgentQuestionObject id "atom:org.quixos.agent:question";
|
|
atom AgentCompletionStreamObject id "atom:org.quixos.agent:completion-stream";
|
|
type AgentCompletion = record {request:atom-ref<AgentRequestObject>;thread:atom-ref<AgentThreadObject>;status:string;};
|
|
conform Canvas as AgentWorkspace id "agent:conformance:workspace" {
|
|
private edge Linkworkspaceagents id "agent:workspace:agents:edge" {atom Canvas projection agents id "agent:workspace:agents:projection" optional-one on-delete "detach" public-traversal;atom AgentDirectoryObject projection workspaces id "agent:directory:workspaces:projection" many on-delete "detach" public-traversal;}
|
|
bind agents.resolve to edge Linkworkspaceagents.agents.resolve;
|
|
bind install.call to package AgentRuntime.workspace_install with {agents to edge Linkworkspaceagents.agents;
|
|
create_directory to creation AgentDirectoryObject with {AgentDirectory from input;};
|
|
directory to interface AgentDirectory from input;};
|
|
}
|
|
conform AgentDirectoryObject as AgentDirectory id "agent:conformance:directory" {
|
|
private state directorydata id "agent:storage:directory:data" on AgentDirectoryObject : DirectoryData policy register;
|
|
private edge Linkdirectorypending id "agent:directory:pending:edge" {atom AgentDirectoryObject projection pending id "agent:directory:pending:projection" many-unique on-delete "detach" public-traversal;atom AgentRequestObject projection pendingIn id "agent:request:pendingIn:projection" many on-delete "detach" public-traversal;}
|
|
private edge Linkdirectorynotifications id "agent:directory:notifications:edge" {atom AgentDirectoryObject projection notifications id "agent:directory:notifications:projection" many-unique on-delete "detach" public-traversal;atom AgentRequestObject projection notificationIn id "agent:request:notificationIn:projection" many on-delete "detach" public-traversal;}
|
|
private edge LinkdirectorydefaultAgent id "agent:directory:defaultAgent:edge" {atom AgentDirectoryObject projection defaultAgent id "agent:directory:defaultAgent:projection" optional-one on-delete "detach" public-traversal;atom AgentObject projection defaultIn id "agent:agent:defaultIn:projection" many on-delete "detach" public-traversal;}
|
|
private edge LinkdirectoryinitialThread id "agent:directory:initialThread:edge" {atom AgentDirectoryObject projection initialThread id "agent:directory:initialThread:projection" optional-one on-delete "detach" public-traversal;atom AgentThreadObject projection initialIn id "agent:thread:initialIn:projection" many on-delete "detach" public-traversal;}
|
|
private edge Linkdirectoryrepairs id "agent:directory:repairs:edge" {atom AgentDirectoryObject projection repairs id "agent:directory:repairs:projection" many-unique on-delete "detach" keyed "string";atom AgentRequestObject projection repairDirectory id "agent:request:repair-directory:projection" many on-delete "detach";}
|
|
initialize {data to state directorydata;};
|
|
bind data.get to state directorydata.read;
|
|
bind agents.resolve to edge Linkagentdirectory.agents.resolve;
|
|
bind threads.resolve to edge Linkthreaddirectory.threads.resolve;
|
|
bind pending.resolve to edge Linkdirectorypending.pending.resolve;
|
|
bind notifications.resolve to edge Linkdirectorynotifications.notifications.resolve;
|
|
bind defaultAgent.resolve to edge LinkdirectorydefaultAgent.defaultAgent.resolve;
|
|
bind initialThread.resolve to edge LinkdirectoryinitialThread.initialThread.resolve;
|
|
bind createAgent.call to package AgentRuntime.directory_createAgent with {create_agent to creation AgentObject with {Agent from input;};
|
|
create_stream to creation AgentCompletionStreamObject with {};};
|
|
bind createThread.call to package AgentRuntime.directory_createThread with {data to state directorydata;
|
|
create_thread to creation AgentThreadObject with {AgentThread from input;};
|
|
agent to interface Agent from input;};
|
|
bind admit.call to package AgentRuntime.directory_admit with {data to state directorydata;
|
|
root to interface AgentRequest from input;
|
|
pending to edge Linkdirectorypending.pending;
|
|
create_request to creation AgentRequestObject with {AgentRequest from input;};
|
|
create_item to creation AgentItemObject with {AgentItem from input;};
|
|
agent to interface Agent from input;
|
|
thread to interface AgentThread from input;
|
|
directory to interface AgentDirectory from input;};
|
|
bind reconcileRepair.call to package AgentRuntime.directory_reconcileRepair with {data to state directorydata;repairs to edge Linkdirectoryrepairs.repairs;pending to edge Linkdirectorypending.pending;defaultAgent to edge LinkdirectorydefaultAgent.defaultAgent;initialThread to edge LinkdirectoryinitialThread.initialThread;create_request to creation AgentRequestObject with {AgentRequest from input;};create_item to creation AgentItemObject with {AgentItem from input;};request to interface AgentRequest from input;thread to interface AgentThread from input;};
|
|
bind settle.call to package AgentRuntime.directory_settle with {data to state directorydata;
|
|
pending to edge Linkdirectorypending.pending;
|
|
notifications to edge Linkdirectorynotifications.notifications;
|
|
thread to interface AgentThread from input;};
|
|
bind advertise.call to package AgentRuntime.directory_advertise with {data to state directorydata;};
|
|
bind initialize.call to package AgentRuntime.directory_initialize with {defaultAgent to edge LinkdirectorydefaultAgent.defaultAgent;
|
|
initialThread to edge LinkdirectoryinitialThread.initialThread;
|
|
directory to interface AgentDirectory from input;};
|
|
bind notificationSent.call to package AgentRuntime.directory_notificationSent with {notifications to edge Linkdirectorynotifications.notifications;data to state directorydata;};
|
|
}
|
|
conform AgentObject as Agent id "agent:conformance:agent" {
|
|
private state agentdata id "agent:storage:agent:data" on AgentObject : AgentData policy register;
|
|
private state agentinstructions id "agent:storage:agent:instructions" on AgentObject : string policy crdt(string);
|
|
private edge Linkagentdirectory id "agent:agent:directory:edge" {atom AgentObject projection directory id "agent:agent:directory:projection" exactly-one on-delete "detach" public-traversal;atom AgentDirectoryObject projection agents id "agent:directory:agents:projection" many-unique on-delete "detach" public-traversal;}
|
|
private edge Linkagentcompletions id "agent:agent:completions:edge" {atom AgentObject projection completions id "agent:agent:completions:projection" exactly-one on-delete "detach" public-traversal;interface EventStream<AgentCompletion> projection agentOwners id "agent:agent:completions:owners" many on-delete "detach";}
|
|
initialize {data to state agentdata;instructions to state agentinstructions;directory to edge Linkagentdirectory.directory;completions to edge Linkagentcompletions.completions;};
|
|
bind data.get to state agentdata.read;
|
|
bind instructions.get to state agentinstructions.read;
|
|
bind instructions.edit to state agentinstructions.edit;
|
|
bind directory.resolve to edge Linkagentdirectory.directory.resolve;
|
|
bind threads.resolve to edge Linkthreadagent.threads.resolve;
|
|
bind completions.resolve to edge Linkagentcompletions.completions.resolve;
|
|
bind update.call to package AgentRuntime.agent_update with {data to state agentdata;};
|
|
bind createThread.call to package AgentRuntime.agent_createThread with {agent to interface Agent from input;
|
|
directory to interface AgentDirectory from input;};
|
|
bind request.call to package AgentRuntime.agent_request with {agent to interface Agent from input;
|
|
directory to interface AgentDirectory from input;};
|
|
bind tryRequest.call to package AgentRuntime.agent_tryRequest with {agent to interface Agent from input;
|
|
directory to interface AgentDirectory from input;};
|
|
}
|
|
conform AgentThreadObject as AgentThread id "agent:conformance:thread" {
|
|
private state threaddata id "agent:storage:thread:data" on AgentThreadObject : ThreadData policy register;
|
|
private edge Linkthreaddirectory id "agent:thread:directory:edge" {atom AgentThreadObject projection directory id "agent:thread:directory:projection" exactly-one on-delete "detach" public-traversal;atom AgentDirectoryObject projection threads id "agent:directory:threads:projection" many-unique on-delete "detach" public-traversal;}
|
|
private edge Linkthreadagent id "agent:thread:agent:edge" {atom AgentThreadObject projection agent id "agent:thread:agent:projection" exactly-one on-delete "detach" public-traversal;atom AgentObject projection threads id "agent:agent:threads:projection" many-unique on-delete "detach" public-traversal;}
|
|
private edge Linkthreadactive id "agent:thread:active:edge" {atom AgentThreadObject projection active id "agent:thread:active:projection" optional-one on-delete "detach" public-traversal;atom AgentRequestObject projection activeIn id "agent:request:activeIn:projection" many on-delete "detach" public-traversal;}
|
|
private edge Linkthreadcontexts id "agent:thread:contexts:edge" {atom AgentThreadObject projection contexts id "agent:thread:contexts:projection" many-unique on-delete "detach" public-traversal;interface AgentContextSubject projection threadOwners id "agent:thread:contexts:owners" many on-delete "detach";}
|
|
initialize {data to state threaddata;directory to edge Linkthreaddirectory.directory;agent to edge Linkthreadagent.agent;contexts to edge Linkthreadcontexts.contexts;};
|
|
bind data.get to state threaddata.read;
|
|
bind agent.resolve to edge Linkthreadagent.agent.resolve;
|
|
bind directory.resolve to edge Linkthreaddirectory.directory.resolve;
|
|
bind active.resolve to edge Linkthreadactive.active.resolve;
|
|
bind requests.resolve to edge Linkrequestthread.requests.resolve;
|
|
bind items.resolve to edge Linkitemthread.items.resolve;
|
|
bind contexts.resolve to edge Linkthreadcontexts.contexts.resolve;
|
|
bind send.call to package AgentRuntime.thread_send with {thread to interface AgentThread from input;
|
|
directory to interface AgentDirectory from input;};
|
|
bind rename.call to package AgentRuntime.thread_rename with {data to state threaddata;};
|
|
bind archive.call to package AgentRuntime.thread_archive with {data to state threaddata;};
|
|
bind activate.call to package AgentRuntime.thread_activate with {active to edge Linkthreadactive.active;};
|
|
bind release.call to package AgentRuntime.thread_release with {active to edge Linkthreadactive.active;};
|
|
bind adjustPending.call to package AgentRuntime.thread_adjustPending with {data to state threaddata;};
|
|
bind allocateItem.call to package AgentRuntime.thread_allocateItem with {data to state threaddata;};
|
|
}
|
|
conform AgentRequestObject as AgentRequest id "agent:conformance:request" {
|
|
private state requestspawned id "agent:storage:request:spawned" on AgentRequestObject : uint32 policy register;
|
|
private state requestprogress id "agent:storage:request:progress" on AgentRequestObject : RequestState policy register;
|
|
private state requestadmission id "agent:storage:request:admission" on AgentRequestObject : RequestData policy register;
|
|
private edge Linkrequestthread id "agent:request:thread:edge" {atom AgentRequestObject projection thread id "agent:request:thread:projection" exactly-one on-delete "detach" public-traversal;atom AgentThreadObject projection requests id "agent:thread:requests:projection" many-unique on-delete "detach" public-traversal;}
|
|
private edge Linkrequestdirectory id "agent:request:directory:edge" {atom AgentRequestObject projection directory id "agent:request:directory:projection" exactly-one on-delete "detach" public-traversal;atom AgentDirectoryObject projection allRequests id "agent:directory:allRequests:projection" many-unique on-delete "detach" public-traversal;}
|
|
private edge Linkrequestrelated id "agent:request:related:edge" {atom AgentRequestObject projection related id "agent:request:related:projection" optional-one on-delete "detach" public-traversal;atom AgentRequestObject projection relatedFrom id "agent:request:relatedFrom:projection" many on-delete "detach" public-traversal;}
|
|
private edge LinkrequestretryOf id "agent:request:retryOf:edge" {atom AgentRequestObject projection retryOf id "agent:request:retryOf:projection" optional-one on-delete "detach" public-traversal;atom AgentRequestObject projection retries id "agent:request:retries:projection" many on-delete "detach" public-traversal;}
|
|
private edge Linkrequestroot id "agent:request:root:edge" {atom AgentRequestObject projection root id "agent:request:root:projection" optional-one on-delete "detach" public-traversal;atom AgentRequestObject projection descendants id "agent:request:descendants:projection" many on-delete "detach" public-traversal;}
|
|
private edge Linkrequestcontexts id "agent:request:contexts:edge" {atom AgentRequestObject projection contexts id "agent:request:contexts:projection" many-unique on-delete "detach" public-traversal;interface AgentContextSubject projection requestOwners id "agent:request:contexts:owners" many on-delete "detach";}
|
|
initialize {spawned to state requestspawned;admission to state requestadmission;progress to state requestprogress;contexts to edge Linkrequestcontexts.contexts;directory to edge Linkrequestdirectory.directory;thread to edge Linkrequestthread.thread;related to edge Linkrequestrelated.related;retryOf to edge LinkrequestretryOf.retryOf;root to edge Linkrequestroot.root;};
|
|
bind spawned.get to state requestspawned.read;
|
|
bind reserveChild.call to package AgentRuntime.request_reserveChild with {spawned to state requestspawned;};
|
|
bind admission.get to state requestadmission.read;
|
|
bind progress.get to state requestprogress.read;
|
|
bind thread.resolve to edge Linkrequestthread.thread.resolve;
|
|
bind directory.resolve to edge Linkrequestdirectory.directory.resolve;
|
|
bind items.resolve to edge Linkitemrequest.items.resolve;
|
|
bind questions.resolve to edge Linkquestionrequest.questions.resolve;
|
|
bind contexts.resolve to edge Linkrequestcontexts.contexts.resolve;
|
|
bind related.resolve to edge Linkrequestrelated.related.resolve;
|
|
bind retryOf.resolve to edge LinkrequestretryOf.retryOf.resolve;
|
|
bind root.resolve to edge Linkrequestroot.root.resolve;
|
|
private edge Linkrequestcorrection id "agent:request:correction:edge" {atom AgentRequestObject projection correction id "agent:request:correction:projection" optional-one on-delete "detach";atom AgentRequestObject projection correctionOf id "agent:request:correctionOf:projection" optional-one on-delete "detach";}
|
|
bind correct.call to package AgentRuntime.request_correct with {correction to edge Linkrequestcorrection.correction;request to interface AgentRequest from input;thread to interface AgentThread from input;};
|
|
bind claim.call to package AgentRuntime.request_claim with {progress to state requestprogress;
|
|
request to interface AgentRequest from input;
|
|
thread to interface AgentThread from input;};
|
|
bind transition.call to package AgentRuntime.request_transition with {progress to state requestprogress;};
|
|
bind finish.call to package AgentRuntime.request_finish with {progress to state requestprogress;
|
|
admission to state requestadmission;
|
|
request to interface AgentRequest from input;
|
|
directory to interface AgentDirectory from input;
|
|
thread to interface AgentThread from input;
|
|
agent to interface Agent from input;};
|
|
bind cancel.call to package AgentRuntime.request_cancel with {progress to state requestprogress;
|
|
request to interface AgentRequest from input;};
|
|
bind steer.call to package AgentRuntime.request_steer with {progress to state requestprogress;
|
|
request to interface AgentRequest from input;
|
|
directory to interface AgentDirectory from input;};
|
|
bind upsertItem.call to package AgentRuntime.request_upsertItem with {progress to state requestprogress;
|
|
request to interface AgentRequest from input;
|
|
thread to interface AgentThread from input;
|
|
item to interface AgentItem from input;
|
|
presentable to interface WebStudioPresentable from input;
|
|
create_mount to creation PresentationMountRecord with {};
|
|
create_item to creation AgentItemObject with {AgentItem from input;};};
|
|
bind ask.call to package AgentRuntime.request_ask with {progress to state requestprogress;
|
|
request to interface AgentRequest from input;
|
|
question to interface AgentQuestion from input;
|
|
create_question to creation AgentQuestionObject with {AgentQuestion from input;};};
|
|
bind publishCompletion.call to package AgentRuntime.request_publishCompletion with {progress to state requestprogress;
|
|
request to interface AgentRequest from input;
|
|
thread to interface AgentThread from input;
|
|
agent to interface Agent from input;
|
|
stream to interface EventStream<AgentCompletion> from input;
|
|
directory to interface AgentDirectory from input;};
|
|
}
|
|
conform AgentItemObject as AgentItem id "agent:conformance:item" {
|
|
private state itemdata id "agent:storage:item:data" on AgentItemObject : ItemData policy register;
|
|
private edge Linkitemrequest id "agent:item:request:edge" {atom AgentItemObject projection request id "agent:item:request:projection" exactly-one on-delete "detach" public-traversal;atom AgentRequestObject projection items id "agent:request:items:projection" many-unique on-delete "detach" public-traversal;}
|
|
private edge Linkitemthread id "agent:item:thread:edge" {atom AgentItemObject projection thread id "agent:item:thread:projection" exactly-one on-delete "detach" public-traversal;atom AgentThreadObject projection items id "agent:thread:items:projection" many-unique on-delete "detach" public-traversal;}
|
|
private edge Linkitemsubject id "agent:item:subject:edge" {atom AgentItemObject projection subject id "agent:item:subject:projection" optional-one on-delete "detach" public-traversal;interface WebStudioPresentable projection itemOwners id "agent:item:subject:owners" many on-delete "detach";}
|
|
private edge Linkitemmount id "agent:item:mount:edge" {atom AgentItemObject projection presentationMount id "agent:item:mount:projection" optional-one on-delete "detach" public-traversal;interface PresentationMount projection itemOwners id "agent:item:mount:owners" many on-delete "detach";}
|
|
bind presentationMount.resolve to edge Linkitemmount.presentationMount.resolve;
|
|
initialize {presentationMount to edge Linkitemmount.presentationMount;data to state itemdata;thread to edge Linkitemthread.thread;request to edge Linkitemrequest.request;subject to edge Linkitemsubject.subject;};
|
|
bind data.get to state itemdata.read;
|
|
bind request.resolve to edge Linkitemrequest.request.resolve;
|
|
bind thread.resolve to edge Linkitemthread.thread.resolve;
|
|
bind subject.resolve to edge Linkitemsubject.subject.resolve;
|
|
bind checkpoint.call to package AgentRuntime.item_checkpoint with {data to state itemdata;item to interface AgentItem from input;request to interface AgentRequest from input;};
|
|
}
|
|
conform AgentQuestionObject as AgentQuestion id "agent:conformance:question" {
|
|
private state questiondata id "agent:storage:question:data" on AgentQuestionObject : QuestionData policy register;
|
|
private edge Linkquestionrequest id "agent:question:request:edge" {atom AgentQuestionObject projection request id "agent:question:request:projection" exactly-one on-delete "detach" public-traversal;atom AgentRequestObject projection questions id "agent:request:questions:projection" many-unique on-delete "detach" public-traversal;}
|
|
initialize {data to state questiondata;request to edge Linkquestionrequest.request;};
|
|
bind data.get to state questiondata.read;
|
|
bind request.resolve to edge Linkquestionrequest.request.resolve;
|
|
bind answer.call to package AgentRuntime.question_answer with {data to state questiondata;
|
|
question to interface AgentQuestion from input;
|
|
request to interface AgentRequest from input;};
|
|
bind cancel.call to package AgentRuntime.question_cancel with {data to state questiondata;};
|
|
}
|
|
conform AgentCompletionStreamObject as EventStream<AgentCompletion> id "agent:completion-stream" {private state Entries id "agent:completion:entries" on AgentCompletionStreamObject : AgentCompletion policy journal {"maxEntries":128,"maxBytes":1048576,"maxPublicationBytes":262144,"maxProtectedSubscriptions":32};bind publish.call to journal Entries.publish;bind head.get to journal Entries.head;bind readPage.call to journal Entries.readPage;}
|
|
presentation ThreadView id "presentation:org.quixos.agent:thread" for AgentThread using AgentPresentation.Thread;
|
|
conform AgentThreadObject as StandaloneView<interface AgentThread> id "agent:thread:view" {bind render to AgentPresentation.Thread;}
|
|
conform AgentThreadObject as WebStudioPresentable id "agent:thread:presentable" {bind canPresent.call to package WebStudioCanvasRuntime.canPresent<atom AgentThreadObject> with {catalog to workspace reflection [presentations];};}
|
|
}
|