@jini-ai/agentic 0.1.0

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 (82) hide show
  1. package/LICENSE +201 -0
  2. package/dist/ag-ui.d.ts +82 -0
  3. package/dist/ag-ui.d.ts.map +1 -0
  4. package/dist/ag-ui.js +56 -0
  5. package/dist/ag-ui.js.map +1 -0
  6. package/dist/agui/encoder.d.ts +50 -0
  7. package/dist/agui/encoder.d.ts.map +1 -0
  8. package/dist/agui/encoder.js +97 -0
  9. package/dist/agui/encoder.js.map +1 -0
  10. package/dist/agui/events.d.ts +59 -0
  11. package/dist/agui/events.d.ts.map +1 -0
  12. package/dist/agui/events.js +15 -0
  13. package/dist/agui/events.js.map +1 -0
  14. package/dist/capability.d.ts +81 -0
  15. package/dist/capability.d.ts.map +1 -0
  16. package/dist/capability.js +79 -0
  17. package/dist/capability.js.map +1 -0
  18. package/dist/dom/dom-page-driver.d.ts +29 -0
  19. package/dist/dom/dom-page-driver.d.ts.map +1 -0
  20. package/dist/dom/dom-page-driver.js +557 -0
  21. package/dist/dom/dom-page-driver.js.map +1 -0
  22. package/dist/dom/index.d.ts +17 -0
  23. package/dist/dom/index.d.ts.map +1 -0
  24. package/dist/dom/index.js +17 -0
  25. package/dist/dom/index.js.map +1 -0
  26. package/dist/dom/model-context.d.ts +54 -0
  27. package/dist/dom/model-context.d.ts.map +1 -0
  28. package/dist/dom/model-context.js +36 -0
  29. package/dist/dom/model-context.js.map +1 -0
  30. package/dist/element-handles.d.ts +99 -0
  31. package/dist/element-handles.d.ts.map +1 -0
  32. package/dist/element-handles.js +39 -0
  33. package/dist/element-handles.js.map +1 -0
  34. package/dist/gen-ui/encoder.d.ts +50 -0
  35. package/dist/gen-ui/encoder.d.ts.map +1 -0
  36. package/dist/gen-ui/encoder.js +97 -0
  37. package/dist/gen-ui/encoder.js.map +1 -0
  38. package/dist/gen-ui/events.d.ts +59 -0
  39. package/dist/gen-ui/events.d.ts.map +1 -0
  40. package/dist/gen-ui/events.js +15 -0
  41. package/dist/gen-ui/events.js.map +1 -0
  42. package/dist/gen-ui/index.d.ts +18 -0
  43. package/dist/gen-ui/index.d.ts.map +1 -0
  44. package/dist/gen-ui/index.js +17 -0
  45. package/dist/gen-ui/index.js.map +1 -0
  46. package/dist/guards.d.ts +91 -0
  47. package/dist/guards.d.ts.map +1 -0
  48. package/dist/guards.js +181 -0
  49. package/dist/guards.js.map +1 -0
  50. package/dist/handle.d.ts +41 -0
  51. package/dist/handle.d.ts.map +1 -0
  52. package/dist/handle.js +41 -0
  53. package/dist/handle.js.map +1 -0
  54. package/dist/index.d.ts +65 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +64 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/mcp-ui-apps.d.ts +133 -0
  59. package/dist/mcp-ui-apps.d.ts.map +1 -0
  60. package/dist/mcp-ui-apps.js +134 -0
  61. package/dist/mcp-ui-apps.js.map +1 -0
  62. package/dist/mcp-ui.d.ts +133 -0
  63. package/dist/mcp-ui.d.ts.map +1 -0
  64. package/dist/mcp-ui.js +134 -0
  65. package/dist/mcp-ui.js.map +1 -0
  66. package/dist/page-capabilities.d.ts +14 -0
  67. package/dist/page-capabilities.d.ts.map +1 -0
  68. package/dist/page-capabilities.js +129 -0
  69. package/dist/page-capabilities.js.map +1 -0
  70. package/dist/page-driver.d.ts +107 -0
  71. package/dist/page-driver.d.ts.map +1 -0
  72. package/dist/page-driver.js +2 -0
  73. package/dist/page-driver.js.map +1 -0
  74. package/dist/page-executor.d.ts +87 -0
  75. package/dist/page-executor.d.ts.map +1 -0
  76. package/dist/page-executor.js +288 -0
  77. package/dist/page-executor.js.map +1 -0
  78. package/dist/webmcp.d.ts +81 -0
  79. package/dist/webmcp.d.ts.map +1 -0
  80. package/dist/webmcp.js +67 -0
  81. package/dist/webmcp.js.map +1 -0
  82. package/package.json +56 -0
package/dist/webmcp.js ADDED
@@ -0,0 +1,67 @@
1
+ /** Thrown in place of executing, when a call needed confirmation and did not get it. */
2
+ export class WebMcpConfirmationRequiredError extends Error {
3
+ capabilityId;
4
+ reason;
5
+ constructor(capabilityId, reason) {
6
+ super(reason === 'declined'
7
+ ? `WebMCP: "${capabilityId}" was declined by the user`
8
+ : `WebMCP: "${capabilityId}" requires confirmation, but no requestUserInteraction handler was supplied`);
9
+ this.capabilityId = capabilityId;
10
+ this.reason = reason;
11
+ this.name = 'WebMcpConfirmationRequiredError';
12
+ }
13
+ }
14
+ /**
15
+ * Projects one capability into a WebMCP registration.
16
+ *
17
+ * **The confirmation gate is fail-closed.** A capability with `requiresConfirmation` will not run
18
+ * unless `options.requestUserInteraction` is supplied *and* resolves `true`. Omitting the handler
19
+ * does not silently downgrade to "just run it" — it makes the tool permanently refuse, which is
20
+ * the only safe reading of a manifest that asked for confirmation.
21
+ *
22
+ * This does not make WebMCP governed. It is a page-local gate over a path that still has no run,
23
+ * no principal, no `ToolExecutor` and no audit trail (see this package's `frontend-session-registry`
24
+ * note and §11 of the capability report). It closes the *accidental* case — a destructive
25
+ * capability reaching the page with nothing in front of it — not the authorization gap.
26
+ *
27
+ * @param capability - The capability to expose.
28
+ * @param execute - Runs the capability. Receives the raw argument object; the caller is
29
+ * responsible for validating it against `capability.inputSchema` — WebMCP does not.
30
+ * @param options - Optional confirmation handler; required in practice for any capability
31
+ * declaring `requiresConfirmation`.
32
+ * @returns The registration object to hand to `registerTool`.
33
+ * @throws {@link WebMcpConfirmationRequiredError} from `execute`, when confirmation is required
34
+ * and is either declined or unobtainable.
35
+ */
36
+ export function toWebMcpTool(capability, execute, options = {}) {
37
+ return {
38
+ name: capability.id,
39
+ description: capability.description,
40
+ inputSchema: capability.inputSchema,
41
+ execute: async (args) => {
42
+ const input = args ?? {};
43
+ if (capability.requiresConfirmation === true) {
44
+ const { requestUserInteraction } = options;
45
+ if (!requestUserInteraction) {
46
+ throw new WebMcpConfirmationRequiredError(capability.id, 'no-handler');
47
+ }
48
+ const approved = await requestUserInteraction({ capability, args: input });
49
+ if (approved !== true) {
50
+ throw new WebMcpConfirmationRequiredError(capability.id, 'declined');
51
+ }
52
+ }
53
+ return execute(capability.id, input);
54
+ },
55
+ };
56
+ }
57
+ /**
58
+ * Projects a whole manifest.
59
+ *
60
+ * @param capabilities - Capabilities to expose, already filtered by whatever policy applies.
61
+ * @param execute - Shared dispatcher, keyed by capability id.
62
+ * @returns One registration per capability, in manifest order.
63
+ */
64
+ export function toWebMcpTools(capabilities, execute, options = {}) {
65
+ return capabilities.map((capability) => toWebMcpTool(capability, execute, options));
66
+ }
67
+ //# sourceMappingURL=webmcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webmcp.js","sourceRoot":"","sources":["../src/webmcp.ts"],"names":[],"mappings":"AAgDA,wFAAwF;AACxF,MAAM,OAAO,+BAAgC,SAAQ,KAAK;IACnC;IAA+B;IAApD,YAAqB,YAAoB,EAAW,MAAiC;QACnF,KAAK,CACH,MAAM,KAAK,UAAU;YACnB,CAAC,CAAC,YAAY,YAAY,4BAA4B;YACtD,CAAC,CAAC,YAAY,YAAY,6EAA6E,CAC1G,CAAC;QALiB,iBAAY,GAAZ,YAAY,CAAQ;QAAW,WAAM,GAAN,MAAM,CAA2B;QAMnF,IAAI,CAAC,IAAI,GAAG,iCAAiC,CAAC;IAChD,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,YAAY,CAC1B,UAAyB,EACzB,OAAwE,EACxE,UAA+B,EAAE;IAEjC,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,EAAE;QACnB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YACtB,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;YACzB,IAAI,UAAU,CAAC,oBAAoB,KAAK,IAAI,EAAE,CAAC;gBAC7C,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC;gBAC3C,IAAI,CAAC,sBAAsB,EAAE,CAAC;oBAC5B,MAAM,IAAI,+BAA+B,CAAC,UAAU,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;gBACzE,CAAC;gBACD,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;gBAC3E,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;oBACtB,MAAM,IAAI,+BAA+B,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;gBACvE,CAAC;YACH,CAAC;YACD,OAAO,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,YAAsC,EACtC,OAAwE,EACxE,UAA+B,EAAE;IAEjC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACtF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@jini-ai/agentic",
3
+ "version": "0.1.0",
4
+ "license": "Apache-2.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/AINSEP/Jini.git",
8
+ "directory": "packages/agentic"
9
+ },
10
+ "jini": {
11
+ "domain": "agent",
12
+ "kind": "capability-surface",
13
+ "runtime": "universal",
14
+ "admission": "admitted",
15
+ "entries": {
16
+ ".": "universal",
17
+ "./dom": "browser"
18
+ }
19
+ },
20
+ "type": "module",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ },
26
+ "./dom": {
27
+ "types": "./dist/dom/index.d.ts",
28
+ "import": "./dist/dom/index.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "!dist/**/*.test.js",
34
+ "!dist/**/*.test.d.ts",
35
+ "!dist/**/*.test.js.map",
36
+ "!dist/**/*.test.d.ts.map",
37
+ "!dist/**/__tests__/**"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "registry": "https://registry.npmjs.org"
42
+ },
43
+ "dependencies": {
44
+ "@jini-ai/protocol": "0.1.0"
45
+ },
46
+ "devDependencies": {
47
+ "@vitest/coverage-v8": "^2.1.9",
48
+ "jsdom": "^25.0.1"
49
+ },
50
+ "scripts": {
51
+ "build": "tsc -p tsconfig.json && tsc -p tsconfig.dom.json",
52
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.dom.json --noEmit",
53
+ "test": "vitest run",
54
+ "test:coverage": "vitest run --coverage"
55
+ }
56
+ }