@cynodia/axiom-agent-api 0.5.2-alpha.1 → 0.6.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionDef, Density, DeviceClass, DiagnosticNode, FormNode, NodeId, Presentation, PresentationRole, ResolvedPresentation, ResolvedResponsive, StateDef, Theme, UINode, UxRole, ValidationIssue, ViewNode } from '@cynodia/axiom-core';
|
|
1
|
+
import type { ActionDef, Authority, AuthorityContext, Density, DeviceClass, DiagnosticNode, FormNode, NodeId, Expression, Presentation, PresentationRole, ResolvedPresentation, ResolvedResponsive, StateDef, Theme, UINode, UxRole, ValidationIssue, ViewNode } from '@cynodia/axiom-core';
|
|
2
2
|
import { GraphQueries } from './queries.js';
|
|
3
3
|
/** One grouped part of a form, and what it contains. */
|
|
4
4
|
export interface FormSectionSummary {
|
|
@@ -81,6 +81,36 @@ export declare class PresentationQueries extends GraphQueries {
|
|
|
81
81
|
* nothing invokes has no refusal to explain.
|
|
82
82
|
*/
|
|
83
83
|
getActionsWithoutDiagnosticPresentation(): ActionDef[];
|
|
84
|
+
/**
|
|
85
|
+
* Who may commit this state. Absent metadata means `'client'`, so a 0.5.x graph answers
|
|
86
|
+
* `'client'` for everything.
|
|
87
|
+
*/
|
|
88
|
+
getAuthority(stateId: NodeId): Authority | undefined;
|
|
89
|
+
/** Where this action executes. Derived from what it writes, never declared. */
|
|
90
|
+
getActionAuthority(actionId: NodeId): Authority | undefined;
|
|
91
|
+
/** Actions the client must send to the authority rather than execute itself. */
|
|
92
|
+
getServerActions(): ActionDef[];
|
|
93
|
+
/** States a client may commit directly. */
|
|
94
|
+
getClientWritableStates(): StateDef[];
|
|
95
|
+
/** States only the authority may commit. */
|
|
96
|
+
getServerWritableStates(): StateDef[];
|
|
97
|
+
/** States the client never receives at all. */
|
|
98
|
+
getServerOnlyStates(): StateDef[];
|
|
99
|
+
/** Actions that write any server-authoritative state, with the states each touches. */
|
|
100
|
+
getActionsAffectingServerState(): Array<{
|
|
101
|
+
action: ActionDef;
|
|
102
|
+
stateIds: NodeId[];
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* The rule deciding whether a caller may invoke this action, or `undefined` when there is
|
|
106
|
+
* none — in which case every caller may.
|
|
107
|
+
*/
|
|
108
|
+
getAuthorizationForAction(actionId: NodeId): Expression | undefined;
|
|
109
|
+
/** Server actions whose invocation no authorization rule restricts. */
|
|
110
|
+
getUnauthorizedServerActions(): ActionDef[];
|
|
111
|
+
/** Where a state's committed value survives. */
|
|
112
|
+
getPersistenceForState(stateId: NodeId): StateDef['persistence'];
|
|
113
|
+
protected authority(): AuthorityContext;
|
|
84
114
|
/** States marked as ephemeral presentation state rather than domain facts. */
|
|
85
115
|
getEphemeralStates(): StateDef[];
|
|
86
116
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isUINode, primaryChildIds, resolvePresentationMap, uiChildIds, validateGraph, } from '@cynodia/axiom-core';
|
|
1
|
+
import { actionAuthority, authorityContext, isUINode, primaryChildIds, resolvePresentationMap, stateAuthority, uiChildIds, validateGraph, } from '@cynodia/axiom-core';
|
|
2
|
+
import { statesWrittenBy } from '@cynodia/axiom-core';
|
|
2
3
|
import { GraphQueries } from './queries.js';
|
|
3
4
|
/** Diagnostic codes produced by the presentation layer. */
|
|
4
5
|
const PRESENTATION_CODES = [
|
|
@@ -131,6 +132,70 @@ export class PresentationQueries extends GraphQueries {
|
|
|
131
132
|
return canRefuse;
|
|
132
133
|
});
|
|
133
134
|
}
|
|
135
|
+
// -------------------------------------------------------------- authority
|
|
136
|
+
/**
|
|
137
|
+
* Who may commit this state. Absent metadata means `'client'`, so a 0.5.x graph answers
|
|
138
|
+
* `'client'` for everything.
|
|
139
|
+
*/
|
|
140
|
+
getAuthority(stateId) {
|
|
141
|
+
const state = this.graph.getNode(stateId);
|
|
142
|
+
return state?.kind === 'state' ? stateAuthority(state) : undefined;
|
|
143
|
+
}
|
|
144
|
+
/** Where this action executes. Derived from what it writes, never declared. */
|
|
145
|
+
getActionAuthority(actionId) {
|
|
146
|
+
const action = this.graph.getNode(actionId);
|
|
147
|
+
return action?.kind === 'action' ? actionAuthority(action, this.authority()) : undefined;
|
|
148
|
+
}
|
|
149
|
+
/** Actions the client must send to the authority rather than execute itself. */
|
|
150
|
+
getServerActions() {
|
|
151
|
+
const context = this.authority();
|
|
152
|
+
return this.graph
|
|
153
|
+
.getNodesByKind('action')
|
|
154
|
+
.filter((action) => actionAuthority(action, context) === 'server');
|
|
155
|
+
}
|
|
156
|
+
/** States a client may commit directly. */
|
|
157
|
+
getClientWritableStates() {
|
|
158
|
+
return this.graph
|
|
159
|
+
.getNodesByKind('state')
|
|
160
|
+
.filter((state) => !state.derivation && stateAuthority(state) === 'client');
|
|
161
|
+
}
|
|
162
|
+
/** States only the authority may commit. */
|
|
163
|
+
getServerWritableStates() {
|
|
164
|
+
return this.graph
|
|
165
|
+
.getNodesByKind('state')
|
|
166
|
+
.filter((state) => !state.derivation && stateAuthority(state) === 'server');
|
|
167
|
+
}
|
|
168
|
+
/** States the client never receives at all. */
|
|
169
|
+
getServerOnlyStates() {
|
|
170
|
+
return this.graph.getNodesByKind('state').filter((state) => state.serverOnly === true);
|
|
171
|
+
}
|
|
172
|
+
/** Actions that write any server-authoritative state, with the states each touches. */
|
|
173
|
+
getActionsAffectingServerState() {
|
|
174
|
+
const context = this.authority();
|
|
175
|
+
const server = new Set(this.getServerWritableStates().map((state) => state.id));
|
|
176
|
+
return this.getServerActions().map((action) => ({
|
|
177
|
+
action,
|
|
178
|
+
stateIds: [...statesWrittenBy(action, context)].filter((id) => server.has(id)),
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The rule deciding whether a caller may invoke this action, or `undefined` when there is
|
|
183
|
+
* none — in which case every caller may.
|
|
184
|
+
*/
|
|
185
|
+
getAuthorizationForAction(actionId) {
|
|
186
|
+
return this.graph.getNode(actionId)?.authorization;
|
|
187
|
+
}
|
|
188
|
+
/** Server actions whose invocation no authorization rule restricts. */
|
|
189
|
+
getUnauthorizedServerActions() {
|
|
190
|
+
return this.getServerActions().filter((action) => !action.authorization);
|
|
191
|
+
}
|
|
192
|
+
/** Where a state's committed value survives. */
|
|
193
|
+
getPersistenceForState(stateId) {
|
|
194
|
+
return this.graph.getNode(stateId)?.persistence;
|
|
195
|
+
}
|
|
196
|
+
authority() {
|
|
197
|
+
return authorityContext(this.graph.listNodes(), this.graph.principalEntityId);
|
|
198
|
+
}
|
|
134
199
|
/** States marked as ephemeral presentation state rather than domain facts. */
|
|
135
200
|
getEphemeralStates() {
|
|
136
201
|
return this.graph.getNodesByKind('state').filter((state) => state.ephemeral === true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cynodia/axiom-agent-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-alpha.1",
|
|
4
4
|
"description": "Semantic queries and transactional graph transformations for AI agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "AskTech AS",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@cynodia/axiom-core": "0.
|
|
34
|
+
"@cynodia/axiom-core": "0.6.0-alpha.1"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc -b tsconfig.json tsconfig.test.json",
|