@jskit-ai/assistant-runtime 0.1.131-oldline.2 → 0.1.131

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.
Files changed (29) hide show
  1. package/package.json +84 -8
  2. package/patterns/assistant-surface/PATTERN.md +77 -0
  3. package/patterns/assistant-surface/example/config/public.js +19 -0
  4. package/patterns/assistant-surface/example/config/server.js +9 -0
  5. package/patterns/assistant-surface/example/src/pages/admin/assistant/index.vue +7 -0
  6. package/patterns/assistant-surface/example/src/pages/admin/settings/assistant/index.vue +7 -0
  7. package/patterns/assistant-surface/example/src/placement.js +38 -0
  8. package/src/client/components/AssistantSettingsClientElement.vue +1 -1
  9. package/src/client/composables/useAssistantRuntime.js +2 -2
  10. package/src/client/providers/AssistantClientProvider.js +9 -11
  11. package/src/server/AssistantProvider.js +74 -109
  12. package/src/server/actions.js +37 -17
  13. package/src/server/registerRoutes.js +4 -9
  14. package/src/server/repositories/assistantConfigRepository.js +1 -1
  15. package/src/server/repositories/conversationsRepository.js +1 -1
  16. package/src/server/repositories/messagesRepository.js +1 -1
  17. package/src/server/repositories/repositoryPersistenceUtils.js +29 -0
  18. package/src/server/support/createSurfaceAwareToolCatalog.js +5 -5
  19. package/test/actionDefinitions.test.js +49 -142
  20. package/test/assistantSurfacePattern.test.js +30 -0
  21. package/test/createSurfaceAwareToolCatalog.test.js +4 -2
  22. package/test/featureRuntime.test.js +76 -0
  23. package/test/lazyAppConfig.test.js +16 -47
  24. package/test/packageMetadata.test.js +38 -0
  25. package/package.descriptor.mjs +0 -155
  26. package/src/server/support/workspaceScopeSupport.js +0 -47
  27. package/test/packageDescriptor.test.js +0 -38
  28. /package/{templates/migrations → migrations}/assistant_config_initial.cjs +0 -0
  29. /package/{templates/migrations → migrations}/assistant_transcripts_initial.cjs +0 -0
@@ -1,155 +0,0 @@
1
- export default Object.freeze({
2
- packageVersion: 1,
3
- packageId: "@jskit-ai/assistant-runtime",
4
- version: "0.1.131-oldline.2",
5
- kind: "runtime",
6
- description: "Shared assistant runtime with per-surface assistant registration.",
7
- dependsOn: [
8
- "@jskit-ai/assistant-core",
9
- "@jskit-ai/database-runtime",
10
- "@jskit-ai/http-runtime",
11
- "@jskit-ai/shell-web",
12
- "@jskit-ai/users-core",
13
- "@jskit-ai/users-web"
14
- ],
15
- capabilities: {
16
- provides: ["assistant.runtime"],
17
- requires: [
18
- "runtime.actions",
19
- "runtime.database",
20
- "auth.policy",
21
- "runtime.http-client",
22
- "users.core",
23
- "users.web"
24
- ]
25
- },
26
- runtime: {
27
- server: {
28
- providers: [
29
- {
30
- entrypoint: "src/server/AssistantProvider.js",
31
- export: "AssistantProvider"
32
- }
33
- ]
34
- },
35
- client: {
36
- providers: [
37
- {
38
- entrypoint: "src/client/providers/AssistantClientProvider.js",
39
- export: "AssistantClientProvider"
40
- }
41
- ]
42
- }
43
- },
44
- metadata: {
45
- jskit: {
46
- tableOwnership: {
47
- tables: [
48
- {
49
- tableName: "assistant_config",
50
- provenance: "runtime-package",
51
- ownerKind: "package-runtime"
52
- },
53
- {
54
- tableName: "assistant_conversations",
55
- provenance: "runtime-package",
56
- ownerKind: "package-runtime"
57
- },
58
- {
59
- tableName: "assistant_messages",
60
- provenance: "runtime-package",
61
- ownerKind: "package-runtime"
62
- }
63
- ]
64
- }
65
- },
66
- apiSummary: {
67
- surfaces: [
68
- {
69
- subpath: "./client",
70
- summary: "Exports assistant runtime client elements and composables."
71
- },
72
- {
73
- subpath: "./shared",
74
- summary: "Exports assistant runtime shared config helpers."
75
- },
76
- {
77
- subpath: "./server/actionIds",
78
- summary: "Exports assistant runtime action identifiers."
79
- }
80
- ],
81
- containerTokens: {
82
- server: [
83
- "assistant.config.repository",
84
- "assistant.conversation.repository",
85
- "assistant.message.repository",
86
- "assistant.ai.client.factory",
87
- "assistant.service.tool-catalog"
88
- ],
89
- client: [
90
- "assistant.web.settings.element"
91
- ]
92
- }
93
- }
94
- },
95
- mutations: {
96
- dependencies: {
97
- runtime: {
98
- "@jskit-ai/assistant-core": "0.1.124",
99
- "@jskit-ai/database-runtime": "0.1.147",
100
- "@jskit-ai/http-runtime": "0.1.146",
101
- "@jskit-ai/kernel": "0.1.147",
102
- "@jskit-ai/shell-web": "0.1.148",
103
- "@jskit-ai/users-core": "0.1.161",
104
- "@jskit-ai/users-web": "0.1.165"
105
- },
106
- dev: {}
107
- },
108
- packageJson: {
109
- scripts: {}
110
- },
111
- procfile: {},
112
- files: [
113
- {
114
- op: "install-migration",
115
- from: "templates/migrations/assistant_config_initial.cjs",
116
- toDir: "migrations",
117
- extension: ".cjs",
118
- reason: "Install assistant configuration schema migration.",
119
- category: "assistant-runtime",
120
- id: "assistant-runtime-config-initial-schema"
121
- },
122
- {
123
- op: "install-migration",
124
- from: "templates/migrations/assistant_transcripts_initial.cjs",
125
- toDir: "migrations",
126
- extension: ".cjs",
127
- reason: "Install assistant transcript schema migration.",
128
- category: "assistant-runtime",
129
- id: "assistant-runtime-transcripts-initial-schema"
130
- }
131
- ],
132
- text: [
133
- {
134
- op: "append-text",
135
- file: "config/public.js",
136
- position: "bottom",
137
- skipIfContains: "config.assistantSurfaces ||= {};",
138
- value: "\nconfig.assistantSurfaces ||= {};\n",
139
- reason: "Initialize the shared assistant surface registry in public app config.",
140
- category: "assistant-runtime",
141
- id: "assistant-runtime-public-surface-registry-init"
142
- },
143
- {
144
- op: "append-text",
145
- file: "config/server.js",
146
- position: "bottom",
147
- skipIfContains: "config.assistantServer ||= {};",
148
- value: "\nconfig.assistantServer ||= {};\n",
149
- reason: "Initialize the shared assistant server config registry.",
150
- category: "assistant-runtime",
151
- id: "assistant-runtime-server-surface-registry-init"
152
- }
153
- ]
154
- }
155
- });
@@ -1,47 +0,0 @@
1
- import { normalizeSchemaDefinition } from "@jskit-ai/kernel/shared/validators";
2
-
3
- const WORKSPACES_SERVER_SCOPE_SUPPORT_TOKEN = "workspaces.server.scope-support";
4
-
5
- function hasWorkspaceRouteParamsDefinition(value) {
6
- try {
7
- return Boolean(normalizeSchemaDefinition(value, {
8
- context: "assistant-runtime workspace scope support.params",
9
- defaultMode: "patch"
10
- }));
11
- } catch {
12
- return false;
13
- }
14
- }
15
-
16
- function isWorkspaceServerScopeSupport(value) {
17
- return Boolean(
18
- value &&
19
- value.available === true &&
20
- hasWorkspaceRouteParamsDefinition(value.params) &&
21
- typeof value.buildInputFromRouteParams === "function" &&
22
- typeof value.resolveWorkspace === "function"
23
- );
24
- }
25
-
26
- function resolveWorkspaceServerScopeSupport(scope = null, { required = false, caller = "assistant-runtime" } = {}) {
27
- const support =
28
- scope && typeof scope.has === "function" && typeof scope.make === "function" && scope.has(WORKSPACES_SERVER_SCOPE_SUPPORT_TOKEN)
29
- ? scope.make(WORKSPACES_SERVER_SCOPE_SUPPORT_TOKEN)
30
- : null;
31
-
32
- if (isWorkspaceServerScopeSupport(support)) {
33
- return support;
34
- }
35
-
36
- if (required) {
37
- throw new Error(`${caller} requires ${WORKSPACES_SERVER_SCOPE_SUPPORT_TOKEN} for workspace-scoped assistant surfaces.`);
38
- }
39
-
40
- return null;
41
- }
42
-
43
- export {
44
- WORKSPACES_SERVER_SCOPE_SUPPORT_TOKEN,
45
- isWorkspaceServerScopeSupport,
46
- resolveWorkspaceServerScopeSupport
47
- };
@@ -1,38 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import descriptor from "../package.descriptor.mjs";
4
-
5
- function findTextMutation(id) {
6
- const mutations = Array.isArray(descriptor?.mutations?.text) ? descriptor.mutations.text : [];
7
- return mutations.find((entry) => String(entry?.id || "") === id) || null;
8
- }
9
-
10
- function findFileMutation(id) {
11
- const mutations = Array.isArray(descriptor?.mutations?.files) ? descriptor.mutations.files : [];
12
- return mutations.find((entry) => String(entry?.id || "") === id) || null;
13
- }
14
-
15
- test("assistant-runtime descriptor registers runtime providers and initializes assistant config roots", () => {
16
- assert.equal(descriptor.kind, "runtime");
17
- assert.equal(descriptor.packageId, "@jskit-ai/assistant-runtime");
18
- assert.equal(descriptor.dependsOn.includes("@jskit-ai/workspaces-core"), false);
19
- assert.equal(descriptor.dependsOn.includes("@jskit-ai/workspaces-web"), false);
20
- assert.equal(descriptor.capabilities?.requires?.includes("workspaces.core"), false);
21
- assert.equal(descriptor.capabilities?.requires?.includes("workspaces.web"), false);
22
- assert.equal(descriptor.runtime?.server?.providers?.[0]?.entrypoint, "src/server/AssistantProvider.js");
23
- assert.equal(descriptor.runtime?.client?.providers?.[0]?.entrypoint, "src/client/providers/AssistantClientProvider.js");
24
-
25
- const publicInit = findTextMutation("assistant-runtime-public-surface-registry-init");
26
- const serverInit = findTextMutation("assistant-runtime-server-surface-registry-init");
27
-
28
- assert.match(String(publicInit?.value || ""), /config\.assistantSurfaces \|\|= \{\};/);
29
- assert.match(String(serverInit?.value || ""), /config\.assistantServer \|\|= \{\};/);
30
- });
31
-
32
- test("assistant-runtime descriptor ships common assistant migrations", () => {
33
- const configMigration = findFileMutation("assistant-runtime-config-initial-schema");
34
- const transcriptMigration = findFileMutation("assistant-runtime-transcripts-initial-schema");
35
-
36
- assert.equal(configMigration?.from, "templates/migrations/assistant_config_initial.cjs");
37
- assert.equal(transcriptMigration?.from, "templates/migrations/assistant_transcripts_initial.cjs");
38
- });