@contractspec/lib.ai-agent 1.62.0 → 2.0.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.
- package/dist/agent/agent-factory.d.ts +0 -1
- package/dist/agent/agent-factory.js +41 -6
- package/dist/agent/agent.test.d.ts +0 -1
- package/dist/agent/contract-spec-agent.d.ts +0 -1
- package/dist/agent/contract-spec-agent.js +41 -6
- package/dist/agent/index.d.ts +0 -1
- package/dist/agent/index.js +43 -8
- package/dist/agent/json-runner.d.ts +0 -1
- package/dist/agent/json-runner.js +42 -7
- package/dist/agent/json-runner.test.d.ts +0 -1
- package/dist/agent/unified-agent.d.ts +0 -1
- package/dist/agent/unified-agent.js +42 -7
- package/dist/approval/index.d.ts +0 -1
- package/dist/approval/index.js +31 -5
- package/dist/approval/workflow.d.ts +7 -2
- package/dist/approval/workflow.js +31 -5
- package/dist/exporters/claude-agent-exporter.d.ts +0 -1
- package/dist/exporters/claude-agent-exporter.js +4 -4
- package/dist/exporters/index.d.ts +0 -1
- package/dist/exporters/index.js +4 -4
- package/dist/exporters/opencode-exporter.d.ts +0 -1
- package/dist/exporters/opencode-exporter.js +4 -4
- package/dist/exporters/types.d.ts +0 -1
- package/dist/i18n/catalogs/en.d.ts +1 -2
- package/dist/i18n/catalogs/en.js +1 -1
- package/dist/i18n/catalogs/es.d.ts +1 -2
- package/dist/i18n/catalogs/es.js +1 -1
- package/dist/i18n/catalogs/fr.d.ts +1 -2
- package/dist/i18n/catalogs/fr.js +1 -1
- package/dist/i18n/catalogs/index.d.ts +0 -1
- package/dist/i18n/catalogs/index.js +3 -3
- package/dist/i18n/i18n.test.d.ts +0 -1
- package/dist/i18n/index.d.ts +0 -1
- package/dist/i18n/index.js +4 -4
- package/dist/i18n/keys.d.ts +0 -1
- package/dist/i18n/locale.d.ts +0 -1
- package/dist/i18n/messages.d.ts +1 -2
- package/dist/i18n/messages.js +4 -4
- package/dist/index.d.ts +0 -14
- package/dist/index.js +6 -3523
- package/dist/interop/index.d.ts +0 -1
- package/dist/interop/index.js +4 -4
- package/dist/interop/spec-consumer.d.ts +0 -1
- package/dist/interop/spec-consumer.js +4 -4
- package/dist/interop/tool-consumer.d.ts +0 -1
- package/dist/interop/tool-consumer.js +4 -4
- package/dist/interop/types.d.ts +0 -1
- package/dist/knowledge/index.d.ts +0 -1
- package/dist/knowledge/index.js +4 -4
- package/dist/knowledge/injector.d.ts +0 -1
- package/dist/knowledge/injector.js +4 -4
- package/dist/memory/in-memory.d.ts +0 -1
- package/dist/memory/index.d.ts +0 -1
- package/dist/memory/manager.d.ts +0 -1
- package/dist/memory/memory.test.d.ts +0 -1
- package/dist/node/agent/agent-factory.js +41 -6
- package/dist/node/agent/contract-spec-agent.js +41 -6
- package/dist/node/agent/index.js +43 -8
- package/dist/node/agent/json-runner.js +42 -7
- package/dist/node/agent/unified-agent.js +42 -7
- package/dist/node/approval/index.js +31 -5
- package/dist/node/approval/workflow.js +31 -5
- package/dist/node/exporters/claude-agent-exporter.js +4 -4
- package/dist/node/exporters/index.js +4 -4
- package/dist/node/exporters/opencode-exporter.js +4 -4
- package/dist/node/i18n/catalogs/en.js +1 -1
- package/dist/node/i18n/catalogs/es.js +1 -1
- package/dist/node/i18n/catalogs/fr.js +1 -1
- package/dist/node/i18n/catalogs/index.js +3 -3
- package/dist/node/i18n/index.js +4 -4
- package/dist/node/i18n/messages.js +4 -4
- package/dist/node/index.js +6 -3523
- package/dist/node/interop/index.js +4 -4
- package/dist/node/interop/spec-consumer.js +4 -4
- package/dist/node/interop/tool-consumer.js +4 -4
- package/dist/node/knowledge/index.js +4 -4
- package/dist/node/knowledge/injector.js +4 -4
- package/dist/node/providers/claude-agent-sdk/adapter.js +4 -4
- package/dist/node/providers/claude-agent-sdk/index.js +4 -4
- package/dist/node/providers/claude-agent-sdk/tool-bridge.js +4 -4
- package/dist/node/providers/index.js +4 -4
- package/dist/node/providers/opencode-sdk/adapter.js +4 -4
- package/dist/node/providers/opencode-sdk/agent-bridge.js +4 -4
- package/dist/node/providers/opencode-sdk/index.js +4 -4
- package/dist/node/providers/opencode-sdk/tool-bridge.js +4 -4
- package/dist/node/providers/registry.js +4 -4
- package/dist/node/session/index.js +37 -2
- package/dist/node/session/store.js +37 -2
- package/dist/node/spec/index.js +5 -5
- package/dist/node/spec/registry.js +5 -5
- package/dist/node/spec/spec.js +4 -4
- package/dist/node/tools/index.js +4 -4
- package/dist/node/tools/knowledge-tool.js +4 -4
- package/dist/node/tools/mcp-server.js +4 -4
- package/dist/node/tools/tool-adapter.js +4 -4
- package/dist/providers/claude-agent-sdk/adapter.d.ts +0 -1
- package/dist/providers/claude-agent-sdk/adapter.js +4 -4
- package/dist/providers/claude-agent-sdk/index.d.ts +0 -1
- package/dist/providers/claude-agent-sdk/index.js +4 -4
- package/dist/providers/claude-agent-sdk/session-bridge.d.ts +0 -1
- package/dist/providers/claude-agent-sdk/tool-bridge.d.ts +0 -1
- package/dist/providers/claude-agent-sdk/tool-bridge.js +4 -4
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/index.js +4 -4
- package/dist/providers/opencode-sdk/adapter.d.ts +0 -1
- package/dist/providers/opencode-sdk/adapter.js +4 -4
- package/dist/providers/opencode-sdk/agent-bridge.d.ts +0 -1
- package/dist/providers/opencode-sdk/agent-bridge.js +4 -4
- package/dist/providers/opencode-sdk/index.d.ts +0 -1
- package/dist/providers/opencode-sdk/index.js +4 -4
- package/dist/providers/opencode-sdk/tool-bridge.d.ts +0 -1
- package/dist/providers/opencode-sdk/tool-bridge.js +4 -4
- package/dist/providers/registry.d.ts +0 -1
- package/dist/providers/registry.js +4 -4
- package/dist/providers/types.d.ts +0 -1
- package/dist/schema/index.d.ts +0 -1
- package/dist/schema/json-schema-to-zod.d.ts +0 -1
- package/dist/schema/schema-output.d.ts +0 -1
- package/dist/session/index.d.ts +0 -1
- package/dist/session/index.js +37 -2
- package/dist/session/store.d.ts +12 -2
- package/dist/session/store.js +37 -2
- package/dist/spec/index.d.ts +0 -1
- package/dist/spec/index.js +5 -5
- package/dist/spec/registry.d.ts +1 -2
- package/dist/spec/registry.js +5 -5
- package/dist/spec/spec.d.ts +3 -4
- package/dist/spec/spec.js +4 -4
- package/dist/telemetry/adapter.d.ts +0 -1
- package/dist/telemetry/index.d.ts +0 -1
- package/dist/telemetry/posthog-types.d.ts +0 -1
- package/dist/telemetry/posthog.d.ts +0 -1
- package/dist/telemetry/posthog.test.d.ts +0 -1
- package/dist/tools/index.d.ts +0 -1
- package/dist/tools/index.js +4 -4
- package/dist/tools/knowledge-tool.d.ts +0 -1
- package/dist/tools/knowledge-tool.js +4 -4
- package/dist/tools/mcp-client.d.ts +0 -1
- package/dist/tools/mcp-server.d.ts +0 -1
- package/dist/tools/mcp-server.js +4 -4
- package/dist/tools/tool-adapter.d.ts +0 -1
- package/dist/tools/tool-adapter.js +4 -4
- package/dist/tools/tools.test.d.ts +0 -1
- package/dist/types.d.ts +0 -1
- package/package.json +12 -12
- package/dist/agent/agent-factory.d.ts.map +0 -1
- package/dist/agent/agent.test.d.ts.map +0 -1
- package/dist/agent/contract-spec-agent.d.ts.map +0 -1
- package/dist/agent/index.d.ts.map +0 -1
- package/dist/agent/json-runner.d.ts.map +0 -1
- package/dist/agent/json-runner.test.d.ts.map +0 -1
- package/dist/agent/unified-agent.d.ts.map +0 -1
- package/dist/approval/index.d.ts.map +0 -1
- package/dist/approval/workflow.d.ts.map +0 -1
- package/dist/exporters/claude-agent-exporter.d.ts.map +0 -1
- package/dist/exporters/index.d.ts.map +0 -1
- package/dist/exporters/opencode-exporter.d.ts.map +0 -1
- package/dist/exporters/types.d.ts.map +0 -1
- package/dist/i18n/catalogs/en.d.ts.map +0 -1
- package/dist/i18n/catalogs/es.d.ts.map +0 -1
- package/dist/i18n/catalogs/fr.d.ts.map +0 -1
- package/dist/i18n/catalogs/index.d.ts.map +0 -1
- package/dist/i18n/i18n.test.d.ts.map +0 -1
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/i18n/keys.d.ts.map +0 -1
- package/dist/i18n/locale.d.ts.map +0 -1
- package/dist/i18n/messages.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/interop/index.d.ts.map +0 -1
- package/dist/interop/spec-consumer.d.ts.map +0 -1
- package/dist/interop/tool-consumer.d.ts.map +0 -1
- package/dist/interop/types.d.ts.map +0 -1
- package/dist/knowledge/index.d.ts.map +0 -1
- package/dist/knowledge/injector.d.ts.map +0 -1
- package/dist/memory/in-memory.d.ts.map +0 -1
- package/dist/memory/index.d.ts.map +0 -1
- package/dist/memory/manager.d.ts.map +0 -1
- package/dist/memory/memory.test.d.ts.map +0 -1
- package/dist/providers/claude-agent-sdk/adapter.d.ts.map +0 -1
- package/dist/providers/claude-agent-sdk/index.d.ts.map +0 -1
- package/dist/providers/claude-agent-sdk/session-bridge.d.ts.map +0 -1
- package/dist/providers/claude-agent-sdk/tool-bridge.d.ts.map +0 -1
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/opencode-sdk/adapter.d.ts.map +0 -1
- package/dist/providers/opencode-sdk/agent-bridge.d.ts.map +0 -1
- package/dist/providers/opencode-sdk/index.d.ts.map +0 -1
- package/dist/providers/opencode-sdk/tool-bridge.d.ts.map +0 -1
- package/dist/providers/registry.d.ts.map +0 -1
- package/dist/providers/types.d.ts.map +0 -1
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/json-schema-to-zod.d.ts.map +0 -1
- package/dist/schema/schema-output.d.ts.map +0 -1
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/store.d.ts.map +0 -1
- package/dist/spec/index.d.ts.map +0 -1
- package/dist/spec/registry.d.ts.map +0 -1
- package/dist/spec/spec.d.ts.map +0 -1
- package/dist/telemetry/adapter.d.ts.map +0 -1
- package/dist/telemetry/index.d.ts.map +0 -1
- package/dist/telemetry/posthog-types.d.ts.map +0 -1
- package/dist/telemetry/posthog.d.ts.map +0 -1
- package/dist/telemetry/posthog.test.d.ts.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/knowledge-tool.d.ts.map +0 -1
- package/dist/tools/mcp-client.d.ts.map +0 -1
- package/dist/tools/mcp-server.d.ts.map +0 -1
- package/dist/tools/tool-adapter.d.ts.map +0 -1
- package/dist/tools/tools.test.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
|
@@ -13,7 +13,7 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
13
13
|
var __require = import.meta.require;
|
|
14
14
|
|
|
15
15
|
// src/i18n/catalogs/en.ts
|
|
16
|
-
import { defineTranslation } from "@contractspec/lib.contracts/translations";
|
|
16
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
|
|
17
17
|
var enMessages;
|
|
18
18
|
var init_en = __esm(() => {
|
|
19
19
|
enMessages = defineTranslation({
|
|
@@ -609,7 +609,7 @@ var init_en = __esm(() => {
|
|
|
609
609
|
});
|
|
610
610
|
|
|
611
611
|
// src/i18n/catalogs/fr.ts
|
|
612
|
-
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts/translations";
|
|
612
|
+
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
|
|
613
613
|
var frMessages;
|
|
614
614
|
var init_fr = __esm(() => {
|
|
615
615
|
frMessages = defineTranslation2({
|
|
@@ -1220,7 +1220,7 @@ var init_fr = __esm(() => {
|
|
|
1220
1220
|
});
|
|
1221
1221
|
|
|
1222
1222
|
// src/i18n/catalogs/es.ts
|
|
1223
|
-
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts/translations";
|
|
1223
|
+
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
|
|
1224
1224
|
var esMessages;
|
|
1225
1225
|
var init_es = __esm(() => {
|
|
1226
1226
|
esMessages = defineTranslation3({
|
|
@@ -1885,7 +1885,7 @@ var init_locale = __esm(() => {
|
|
|
1885
1885
|
});
|
|
1886
1886
|
|
|
1887
1887
|
// src/i18n/messages.ts
|
|
1888
|
-
import { TranslationRegistry } from "@contractspec/lib.contracts/translations";
|
|
1888
|
+
import { TranslationRegistry } from "@contractspec/lib.contracts-spec/translations";
|
|
1889
1889
|
function getRegistry() {
|
|
1890
1890
|
if (!sharedRegistry) {
|
|
1891
1891
|
sharedRegistry = new TranslationRegistry([
|
|
@@ -2430,10 +2430,19 @@ var init_injector = __esm(() => {
|
|
|
2430
2430
|
// src/session/store.ts
|
|
2431
2431
|
class InMemorySessionStore {
|
|
2432
2432
|
sessions = new Map;
|
|
2433
|
+
maxSessions;
|
|
2434
|
+
maxMessagesPerSession;
|
|
2435
|
+
maxStepsPerSession;
|
|
2436
|
+
constructor(options = {}) {
|
|
2437
|
+
this.maxSessions = options.maxSessions ?? 500;
|
|
2438
|
+
this.maxMessagesPerSession = options.maxMessagesPerSession ?? 200;
|
|
2439
|
+
this.maxStepsPerSession = options.maxStepsPerSession ?? 200;
|
|
2440
|
+
}
|
|
2433
2441
|
async get(sessionId) {
|
|
2434
2442
|
return this.sessions.get(sessionId) ?? null;
|
|
2435
2443
|
}
|
|
2436
2444
|
async create(session) {
|
|
2445
|
+
this.evictIfNeeded();
|
|
2437
2446
|
const now = new Date;
|
|
2438
2447
|
const fullSession = {
|
|
2439
2448
|
...session,
|
|
@@ -2447,6 +2456,7 @@ class InMemorySessionStore {
|
|
|
2447
2456
|
const session = this.sessions.get(sessionId);
|
|
2448
2457
|
if (session) {
|
|
2449
2458
|
session.steps.push(step);
|
|
2459
|
+
this.trimArray(session.steps, this.maxStepsPerSession);
|
|
2450
2460
|
session.updatedAt = new Date;
|
|
2451
2461
|
}
|
|
2452
2462
|
}
|
|
@@ -2454,6 +2464,7 @@ class InMemorySessionStore {
|
|
|
2454
2464
|
const session = this.sessions.get(sessionId);
|
|
2455
2465
|
if (session) {
|
|
2456
2466
|
session.messages.push(message);
|
|
2467
|
+
this.trimArray(session.messages, this.maxMessagesPerSession);
|
|
2457
2468
|
session.updatedAt = new Date;
|
|
2458
2469
|
}
|
|
2459
2470
|
}
|
|
@@ -2491,9 +2502,33 @@ class InMemorySessionStore {
|
|
|
2491
2502
|
clear() {
|
|
2492
2503
|
this.sessions.clear();
|
|
2493
2504
|
}
|
|
2505
|
+
evictIfNeeded() {
|
|
2506
|
+
if (this.sessions.size < this.maxSessions) {
|
|
2507
|
+
return;
|
|
2508
|
+
}
|
|
2509
|
+
let oldestSessionId = null;
|
|
2510
|
+
let oldestUpdatedAt = Number.POSITIVE_INFINITY;
|
|
2511
|
+
for (const [sessionId, session] of this.sessions.entries()) {
|
|
2512
|
+
const updatedAt = session.updatedAt.getTime();
|
|
2513
|
+
if (updatedAt < oldestUpdatedAt) {
|
|
2514
|
+
oldestUpdatedAt = updatedAt;
|
|
2515
|
+
oldestSessionId = sessionId;
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
if (oldestSessionId) {
|
|
2519
|
+
this.sessions.delete(oldestSessionId);
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
trimArray(items, maxItems) {
|
|
2523
|
+
if (items.length <= maxItems) {
|
|
2524
|
+
return;
|
|
2525
|
+
}
|
|
2526
|
+
const overflow = items.length - maxItems;
|
|
2527
|
+
items.splice(0, overflow);
|
|
2528
|
+
}
|
|
2494
2529
|
}
|
|
2495
|
-
function createInMemorySessionStore() {
|
|
2496
|
-
return new InMemorySessionStore;
|
|
2530
|
+
function createInMemorySessionStore(options) {
|
|
2531
|
+
return new InMemorySessionStore(options);
|
|
2497
2532
|
}
|
|
2498
2533
|
function generateSessionId() {
|
|
2499
2534
|
return `sess_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
|
@@ -13,7 +13,7 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
13
13
|
var __require = import.meta.require;
|
|
14
14
|
|
|
15
15
|
// src/i18n/catalogs/en.ts
|
|
16
|
-
import { defineTranslation } from "@contractspec/lib.contracts/translations";
|
|
16
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
|
|
17
17
|
var enMessages;
|
|
18
18
|
var init_en = __esm(() => {
|
|
19
19
|
enMessages = defineTranslation({
|
|
@@ -609,7 +609,7 @@ var init_en = __esm(() => {
|
|
|
609
609
|
});
|
|
610
610
|
|
|
611
611
|
// src/i18n/catalogs/fr.ts
|
|
612
|
-
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts/translations";
|
|
612
|
+
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
|
|
613
613
|
var frMessages;
|
|
614
614
|
var init_fr = __esm(() => {
|
|
615
615
|
frMessages = defineTranslation2({
|
|
@@ -1220,7 +1220,7 @@ var init_fr = __esm(() => {
|
|
|
1220
1220
|
});
|
|
1221
1221
|
|
|
1222
1222
|
// src/i18n/catalogs/es.ts
|
|
1223
|
-
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts/translations";
|
|
1223
|
+
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
|
|
1224
1224
|
var esMessages;
|
|
1225
1225
|
var init_es = __esm(() => {
|
|
1226
1226
|
esMessages = defineTranslation3({
|
|
@@ -1885,7 +1885,7 @@ var init_locale = __esm(() => {
|
|
|
1885
1885
|
});
|
|
1886
1886
|
|
|
1887
1887
|
// src/i18n/messages.ts
|
|
1888
|
-
import { TranslationRegistry } from "@contractspec/lib.contracts/translations";
|
|
1888
|
+
import { TranslationRegistry } from "@contractspec/lib.contracts-spec/translations";
|
|
1889
1889
|
function getRegistry() {
|
|
1890
1890
|
if (!sharedRegistry) {
|
|
1891
1891
|
sharedRegistry = new TranslationRegistry([
|
|
@@ -2430,10 +2430,19 @@ var init_injector = __esm(() => {
|
|
|
2430
2430
|
// src/session/store.ts
|
|
2431
2431
|
class InMemorySessionStore {
|
|
2432
2432
|
sessions = new Map;
|
|
2433
|
+
maxSessions;
|
|
2434
|
+
maxMessagesPerSession;
|
|
2435
|
+
maxStepsPerSession;
|
|
2436
|
+
constructor(options = {}) {
|
|
2437
|
+
this.maxSessions = options.maxSessions ?? 500;
|
|
2438
|
+
this.maxMessagesPerSession = options.maxMessagesPerSession ?? 200;
|
|
2439
|
+
this.maxStepsPerSession = options.maxStepsPerSession ?? 200;
|
|
2440
|
+
}
|
|
2433
2441
|
async get(sessionId) {
|
|
2434
2442
|
return this.sessions.get(sessionId) ?? null;
|
|
2435
2443
|
}
|
|
2436
2444
|
async create(session) {
|
|
2445
|
+
this.evictIfNeeded();
|
|
2437
2446
|
const now = new Date;
|
|
2438
2447
|
const fullSession = {
|
|
2439
2448
|
...session,
|
|
@@ -2447,6 +2456,7 @@ class InMemorySessionStore {
|
|
|
2447
2456
|
const session = this.sessions.get(sessionId);
|
|
2448
2457
|
if (session) {
|
|
2449
2458
|
session.steps.push(step);
|
|
2459
|
+
this.trimArray(session.steps, this.maxStepsPerSession);
|
|
2450
2460
|
session.updatedAt = new Date;
|
|
2451
2461
|
}
|
|
2452
2462
|
}
|
|
@@ -2454,6 +2464,7 @@ class InMemorySessionStore {
|
|
|
2454
2464
|
const session = this.sessions.get(sessionId);
|
|
2455
2465
|
if (session) {
|
|
2456
2466
|
session.messages.push(message);
|
|
2467
|
+
this.trimArray(session.messages, this.maxMessagesPerSession);
|
|
2457
2468
|
session.updatedAt = new Date;
|
|
2458
2469
|
}
|
|
2459
2470
|
}
|
|
@@ -2491,9 +2502,33 @@ class InMemorySessionStore {
|
|
|
2491
2502
|
clear() {
|
|
2492
2503
|
this.sessions.clear();
|
|
2493
2504
|
}
|
|
2505
|
+
evictIfNeeded() {
|
|
2506
|
+
if (this.sessions.size < this.maxSessions) {
|
|
2507
|
+
return;
|
|
2508
|
+
}
|
|
2509
|
+
let oldestSessionId = null;
|
|
2510
|
+
let oldestUpdatedAt = Number.POSITIVE_INFINITY;
|
|
2511
|
+
for (const [sessionId, session] of this.sessions.entries()) {
|
|
2512
|
+
const updatedAt = session.updatedAt.getTime();
|
|
2513
|
+
if (updatedAt < oldestUpdatedAt) {
|
|
2514
|
+
oldestUpdatedAt = updatedAt;
|
|
2515
|
+
oldestSessionId = sessionId;
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
if (oldestSessionId) {
|
|
2519
|
+
this.sessions.delete(oldestSessionId);
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
trimArray(items, maxItems) {
|
|
2523
|
+
if (items.length <= maxItems) {
|
|
2524
|
+
return;
|
|
2525
|
+
}
|
|
2526
|
+
const overflow = items.length - maxItems;
|
|
2527
|
+
items.splice(0, overflow);
|
|
2528
|
+
}
|
|
2494
2529
|
}
|
|
2495
|
-
function createInMemorySessionStore() {
|
|
2496
|
-
return new InMemorySessionStore;
|
|
2530
|
+
function createInMemorySessionStore(options) {
|
|
2531
|
+
return new InMemorySessionStore(options);
|
|
2497
2532
|
}
|
|
2498
2533
|
function generateSessionId() {
|
|
2499
2534
|
return `sess_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
package/dist/agent/index.d.ts
CHANGED
package/dist/agent/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
13
13
|
var __require = import.meta.require;
|
|
14
14
|
|
|
15
15
|
// src/i18n/catalogs/en.ts
|
|
16
|
-
import { defineTranslation } from "@contractspec/lib.contracts/translations";
|
|
16
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
|
|
17
17
|
var enMessages;
|
|
18
18
|
var init_en = __esm(() => {
|
|
19
19
|
enMessages = defineTranslation({
|
|
@@ -609,7 +609,7 @@ var init_en = __esm(() => {
|
|
|
609
609
|
});
|
|
610
610
|
|
|
611
611
|
// src/i18n/catalogs/fr.ts
|
|
612
|
-
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts/translations";
|
|
612
|
+
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
|
|
613
613
|
var frMessages;
|
|
614
614
|
var init_fr = __esm(() => {
|
|
615
615
|
frMessages = defineTranslation2({
|
|
@@ -1220,7 +1220,7 @@ var init_fr = __esm(() => {
|
|
|
1220
1220
|
});
|
|
1221
1221
|
|
|
1222
1222
|
// src/i18n/catalogs/es.ts
|
|
1223
|
-
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts/translations";
|
|
1223
|
+
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
|
|
1224
1224
|
var esMessages;
|
|
1225
1225
|
var init_es = __esm(() => {
|
|
1226
1226
|
esMessages = defineTranslation3({
|
|
@@ -1885,7 +1885,7 @@ var init_locale = __esm(() => {
|
|
|
1885
1885
|
});
|
|
1886
1886
|
|
|
1887
1887
|
// src/i18n/messages.ts
|
|
1888
|
-
import { TranslationRegistry } from "@contractspec/lib.contracts/translations";
|
|
1888
|
+
import { TranslationRegistry } from "@contractspec/lib.contracts-spec/translations";
|
|
1889
1889
|
function getRegistry() {
|
|
1890
1890
|
if (!sharedRegistry) {
|
|
1891
1891
|
sharedRegistry = new TranslationRegistry([
|
|
@@ -2430,10 +2430,19 @@ var init_injector = __esm(() => {
|
|
|
2430
2430
|
// src/session/store.ts
|
|
2431
2431
|
class InMemorySessionStore {
|
|
2432
2432
|
sessions = new Map;
|
|
2433
|
+
maxSessions;
|
|
2434
|
+
maxMessagesPerSession;
|
|
2435
|
+
maxStepsPerSession;
|
|
2436
|
+
constructor(options = {}) {
|
|
2437
|
+
this.maxSessions = options.maxSessions ?? 500;
|
|
2438
|
+
this.maxMessagesPerSession = options.maxMessagesPerSession ?? 200;
|
|
2439
|
+
this.maxStepsPerSession = options.maxStepsPerSession ?? 200;
|
|
2440
|
+
}
|
|
2433
2441
|
async get(sessionId) {
|
|
2434
2442
|
return this.sessions.get(sessionId) ?? null;
|
|
2435
2443
|
}
|
|
2436
2444
|
async create(session) {
|
|
2445
|
+
this.evictIfNeeded();
|
|
2437
2446
|
const now = new Date;
|
|
2438
2447
|
const fullSession = {
|
|
2439
2448
|
...session,
|
|
@@ -2447,6 +2456,7 @@ class InMemorySessionStore {
|
|
|
2447
2456
|
const session = this.sessions.get(sessionId);
|
|
2448
2457
|
if (session) {
|
|
2449
2458
|
session.steps.push(step);
|
|
2459
|
+
this.trimArray(session.steps, this.maxStepsPerSession);
|
|
2450
2460
|
session.updatedAt = new Date;
|
|
2451
2461
|
}
|
|
2452
2462
|
}
|
|
@@ -2454,6 +2464,7 @@ class InMemorySessionStore {
|
|
|
2454
2464
|
const session = this.sessions.get(sessionId);
|
|
2455
2465
|
if (session) {
|
|
2456
2466
|
session.messages.push(message);
|
|
2467
|
+
this.trimArray(session.messages, this.maxMessagesPerSession);
|
|
2457
2468
|
session.updatedAt = new Date;
|
|
2458
2469
|
}
|
|
2459
2470
|
}
|
|
@@ -2491,9 +2502,33 @@ class InMemorySessionStore {
|
|
|
2491
2502
|
clear() {
|
|
2492
2503
|
this.sessions.clear();
|
|
2493
2504
|
}
|
|
2505
|
+
evictIfNeeded() {
|
|
2506
|
+
if (this.sessions.size < this.maxSessions) {
|
|
2507
|
+
return;
|
|
2508
|
+
}
|
|
2509
|
+
let oldestSessionId = null;
|
|
2510
|
+
let oldestUpdatedAt = Number.POSITIVE_INFINITY;
|
|
2511
|
+
for (const [sessionId, session] of this.sessions.entries()) {
|
|
2512
|
+
const updatedAt = session.updatedAt.getTime();
|
|
2513
|
+
if (updatedAt < oldestUpdatedAt) {
|
|
2514
|
+
oldestUpdatedAt = updatedAt;
|
|
2515
|
+
oldestSessionId = sessionId;
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
if (oldestSessionId) {
|
|
2519
|
+
this.sessions.delete(oldestSessionId);
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
trimArray(items, maxItems) {
|
|
2523
|
+
if (items.length <= maxItems) {
|
|
2524
|
+
return;
|
|
2525
|
+
}
|
|
2526
|
+
const overflow = items.length - maxItems;
|
|
2527
|
+
items.splice(0, overflow);
|
|
2528
|
+
}
|
|
2494
2529
|
}
|
|
2495
|
-
function createInMemorySessionStore() {
|
|
2496
|
-
return new InMemorySessionStore;
|
|
2530
|
+
function createInMemorySessionStore(options) {
|
|
2531
|
+
return new InMemorySessionStore(options);
|
|
2497
2532
|
}
|
|
2498
2533
|
function generateSessionId() {
|
|
2499
2534
|
return `sess_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
|
@@ -3990,7 +4025,7 @@ var init_opencode_sdk = __esm(() => {
|
|
|
3990
4025
|
init_i18n();
|
|
3991
4026
|
init_contract_spec_agent();
|
|
3992
4027
|
import { createProvider } from "@contractspec/lib.ai-providers/factory";
|
|
3993
|
-
import { StabilityEnum } from "@contractspec/lib.contracts/ownership";
|
|
4028
|
+
import { StabilityEnum } from "@contractspec/lib.contracts-spec/ownership";
|
|
3994
4029
|
function getJsonOnlyRules(locale) {
|
|
3995
4030
|
const i18n = createAgentI18n(locale);
|
|
3996
4031
|
return [
|
|
@@ -4075,7 +4110,6 @@ async function createAgentJsonRunner(options) {
|
|
|
4075
4110
|
|
|
4076
4111
|
// src/agent/unified-agent.ts
|
|
4077
4112
|
init_i18n();
|
|
4078
|
-
import { createProvider as createProvider2 } from "@contractspec/lib.ai-providers/factory";
|
|
4079
4113
|
|
|
4080
4114
|
class UnifiedAgent {
|
|
4081
4115
|
spec;
|
|
@@ -4241,6 +4275,7 @@ class UnifiedAgent {
|
|
|
4241
4275
|
if (backendConfig?.modelInstance) {
|
|
4242
4276
|
model = backendConfig.modelInstance;
|
|
4243
4277
|
} else if (backendConfig?.provider) {
|
|
4278
|
+
const { createProvider: createProvider2 } = await import("@contractspec/lib.ai-providers/factory");
|
|
4244
4279
|
model = createProvider2(backendConfig.provider).getModel();
|
|
4245
4280
|
} else {
|
|
4246
4281
|
const { anthropic } = await import("@ai-sdk/anthropic");
|
|
@@ -13,7 +13,7 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
13
13
|
var __require = import.meta.require;
|
|
14
14
|
|
|
15
15
|
// src/i18n/catalogs/en.ts
|
|
16
|
-
import { defineTranslation } from "@contractspec/lib.contracts/translations";
|
|
16
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
|
|
17
17
|
var enMessages;
|
|
18
18
|
var init_en = __esm(() => {
|
|
19
19
|
enMessages = defineTranslation({
|
|
@@ -609,7 +609,7 @@ var init_en = __esm(() => {
|
|
|
609
609
|
});
|
|
610
610
|
|
|
611
611
|
// src/i18n/catalogs/fr.ts
|
|
612
|
-
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts/translations";
|
|
612
|
+
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
|
|
613
613
|
var frMessages;
|
|
614
614
|
var init_fr = __esm(() => {
|
|
615
615
|
frMessages = defineTranslation2({
|
|
@@ -1220,7 +1220,7 @@ var init_fr = __esm(() => {
|
|
|
1220
1220
|
});
|
|
1221
1221
|
|
|
1222
1222
|
// src/i18n/catalogs/es.ts
|
|
1223
|
-
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts/translations";
|
|
1223
|
+
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
|
|
1224
1224
|
var esMessages;
|
|
1225
1225
|
var init_es = __esm(() => {
|
|
1226
1226
|
esMessages = defineTranslation3({
|
|
@@ -1885,7 +1885,7 @@ var init_locale = __esm(() => {
|
|
|
1885
1885
|
});
|
|
1886
1886
|
|
|
1887
1887
|
// src/i18n/messages.ts
|
|
1888
|
-
import { TranslationRegistry } from "@contractspec/lib.contracts/translations";
|
|
1888
|
+
import { TranslationRegistry } from "@contractspec/lib.contracts-spec/translations";
|
|
1889
1889
|
function getRegistry() {
|
|
1890
1890
|
if (!sharedRegistry) {
|
|
1891
1891
|
sharedRegistry = new TranslationRegistry([
|
|
@@ -2430,10 +2430,19 @@ var init_injector = __esm(() => {
|
|
|
2430
2430
|
// src/session/store.ts
|
|
2431
2431
|
class InMemorySessionStore {
|
|
2432
2432
|
sessions = new Map;
|
|
2433
|
+
maxSessions;
|
|
2434
|
+
maxMessagesPerSession;
|
|
2435
|
+
maxStepsPerSession;
|
|
2436
|
+
constructor(options = {}) {
|
|
2437
|
+
this.maxSessions = options.maxSessions ?? 500;
|
|
2438
|
+
this.maxMessagesPerSession = options.maxMessagesPerSession ?? 200;
|
|
2439
|
+
this.maxStepsPerSession = options.maxStepsPerSession ?? 200;
|
|
2440
|
+
}
|
|
2433
2441
|
async get(sessionId) {
|
|
2434
2442
|
return this.sessions.get(sessionId) ?? null;
|
|
2435
2443
|
}
|
|
2436
2444
|
async create(session) {
|
|
2445
|
+
this.evictIfNeeded();
|
|
2437
2446
|
const now = new Date;
|
|
2438
2447
|
const fullSession = {
|
|
2439
2448
|
...session,
|
|
@@ -2447,6 +2456,7 @@ class InMemorySessionStore {
|
|
|
2447
2456
|
const session = this.sessions.get(sessionId);
|
|
2448
2457
|
if (session) {
|
|
2449
2458
|
session.steps.push(step);
|
|
2459
|
+
this.trimArray(session.steps, this.maxStepsPerSession);
|
|
2450
2460
|
session.updatedAt = new Date;
|
|
2451
2461
|
}
|
|
2452
2462
|
}
|
|
@@ -2454,6 +2464,7 @@ class InMemorySessionStore {
|
|
|
2454
2464
|
const session = this.sessions.get(sessionId);
|
|
2455
2465
|
if (session) {
|
|
2456
2466
|
session.messages.push(message);
|
|
2467
|
+
this.trimArray(session.messages, this.maxMessagesPerSession);
|
|
2457
2468
|
session.updatedAt = new Date;
|
|
2458
2469
|
}
|
|
2459
2470
|
}
|
|
@@ -2491,9 +2502,33 @@ class InMemorySessionStore {
|
|
|
2491
2502
|
clear() {
|
|
2492
2503
|
this.sessions.clear();
|
|
2493
2504
|
}
|
|
2505
|
+
evictIfNeeded() {
|
|
2506
|
+
if (this.sessions.size < this.maxSessions) {
|
|
2507
|
+
return;
|
|
2508
|
+
}
|
|
2509
|
+
let oldestSessionId = null;
|
|
2510
|
+
let oldestUpdatedAt = Number.POSITIVE_INFINITY;
|
|
2511
|
+
for (const [sessionId, session] of this.sessions.entries()) {
|
|
2512
|
+
const updatedAt = session.updatedAt.getTime();
|
|
2513
|
+
if (updatedAt < oldestUpdatedAt) {
|
|
2514
|
+
oldestUpdatedAt = updatedAt;
|
|
2515
|
+
oldestSessionId = sessionId;
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
if (oldestSessionId) {
|
|
2519
|
+
this.sessions.delete(oldestSessionId);
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
trimArray(items, maxItems) {
|
|
2523
|
+
if (items.length <= maxItems) {
|
|
2524
|
+
return;
|
|
2525
|
+
}
|
|
2526
|
+
const overflow = items.length - maxItems;
|
|
2527
|
+
items.splice(0, overflow);
|
|
2528
|
+
}
|
|
2494
2529
|
}
|
|
2495
|
-
function createInMemorySessionStore() {
|
|
2496
|
-
return new InMemorySessionStore;
|
|
2530
|
+
function createInMemorySessionStore(options) {
|
|
2531
|
+
return new InMemorySessionStore(options);
|
|
2497
2532
|
}
|
|
2498
2533
|
function generateSessionId() {
|
|
2499
2534
|
return `sess_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
|
@@ -2831,7 +2866,7 @@ var init_contract_spec_agent = __esm(() => {
|
|
|
2831
2866
|
init_i18n();
|
|
2832
2867
|
init_contract_spec_agent();
|
|
2833
2868
|
import { createProvider } from "@contractspec/lib.ai-providers/factory";
|
|
2834
|
-
import { StabilityEnum } from "@contractspec/lib.contracts/ownership";
|
|
2869
|
+
import { StabilityEnum } from "@contractspec/lib.contracts-spec/ownership";
|
|
2835
2870
|
function getJsonOnlyRules(locale) {
|
|
2836
2871
|
const i18n = createAgentI18n(locale);
|
|
2837
2872
|
return [
|
|
@@ -13,7 +13,7 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
13
13
|
var __require = import.meta.require;
|
|
14
14
|
|
|
15
15
|
// src/i18n/catalogs/en.ts
|
|
16
|
-
import { defineTranslation } from "@contractspec/lib.contracts/translations";
|
|
16
|
+
import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
|
|
17
17
|
var enMessages;
|
|
18
18
|
var init_en = __esm(() => {
|
|
19
19
|
enMessages = defineTranslation({
|
|
@@ -609,7 +609,7 @@ var init_en = __esm(() => {
|
|
|
609
609
|
});
|
|
610
610
|
|
|
611
611
|
// src/i18n/catalogs/fr.ts
|
|
612
|
-
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts/translations";
|
|
612
|
+
import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
|
|
613
613
|
var frMessages;
|
|
614
614
|
var init_fr = __esm(() => {
|
|
615
615
|
frMessages = defineTranslation2({
|
|
@@ -1220,7 +1220,7 @@ var init_fr = __esm(() => {
|
|
|
1220
1220
|
});
|
|
1221
1221
|
|
|
1222
1222
|
// src/i18n/catalogs/es.ts
|
|
1223
|
-
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts/translations";
|
|
1223
|
+
import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
|
|
1224
1224
|
var esMessages;
|
|
1225
1225
|
var init_es = __esm(() => {
|
|
1226
1226
|
esMessages = defineTranslation3({
|
|
@@ -1885,7 +1885,7 @@ var init_locale = __esm(() => {
|
|
|
1885
1885
|
});
|
|
1886
1886
|
|
|
1887
1887
|
// src/i18n/messages.ts
|
|
1888
|
-
import { TranslationRegistry } from "@contractspec/lib.contracts/translations";
|
|
1888
|
+
import { TranslationRegistry } from "@contractspec/lib.contracts-spec/translations";
|
|
1889
1889
|
function getRegistry() {
|
|
1890
1890
|
if (!sharedRegistry) {
|
|
1891
1891
|
sharedRegistry = new TranslationRegistry([
|
|
@@ -2430,10 +2430,19 @@ var init_injector = __esm(() => {
|
|
|
2430
2430
|
// src/session/store.ts
|
|
2431
2431
|
class InMemorySessionStore {
|
|
2432
2432
|
sessions = new Map;
|
|
2433
|
+
maxSessions;
|
|
2434
|
+
maxMessagesPerSession;
|
|
2435
|
+
maxStepsPerSession;
|
|
2436
|
+
constructor(options = {}) {
|
|
2437
|
+
this.maxSessions = options.maxSessions ?? 500;
|
|
2438
|
+
this.maxMessagesPerSession = options.maxMessagesPerSession ?? 200;
|
|
2439
|
+
this.maxStepsPerSession = options.maxStepsPerSession ?? 200;
|
|
2440
|
+
}
|
|
2433
2441
|
async get(sessionId) {
|
|
2434
2442
|
return this.sessions.get(sessionId) ?? null;
|
|
2435
2443
|
}
|
|
2436
2444
|
async create(session) {
|
|
2445
|
+
this.evictIfNeeded();
|
|
2437
2446
|
const now = new Date;
|
|
2438
2447
|
const fullSession = {
|
|
2439
2448
|
...session,
|
|
@@ -2447,6 +2456,7 @@ class InMemorySessionStore {
|
|
|
2447
2456
|
const session = this.sessions.get(sessionId);
|
|
2448
2457
|
if (session) {
|
|
2449
2458
|
session.steps.push(step);
|
|
2459
|
+
this.trimArray(session.steps, this.maxStepsPerSession);
|
|
2450
2460
|
session.updatedAt = new Date;
|
|
2451
2461
|
}
|
|
2452
2462
|
}
|
|
@@ -2454,6 +2464,7 @@ class InMemorySessionStore {
|
|
|
2454
2464
|
const session = this.sessions.get(sessionId);
|
|
2455
2465
|
if (session) {
|
|
2456
2466
|
session.messages.push(message);
|
|
2467
|
+
this.trimArray(session.messages, this.maxMessagesPerSession);
|
|
2457
2468
|
session.updatedAt = new Date;
|
|
2458
2469
|
}
|
|
2459
2470
|
}
|
|
@@ -2491,9 +2502,33 @@ class InMemorySessionStore {
|
|
|
2491
2502
|
clear() {
|
|
2492
2503
|
this.sessions.clear();
|
|
2493
2504
|
}
|
|
2505
|
+
evictIfNeeded() {
|
|
2506
|
+
if (this.sessions.size < this.maxSessions) {
|
|
2507
|
+
return;
|
|
2508
|
+
}
|
|
2509
|
+
let oldestSessionId = null;
|
|
2510
|
+
let oldestUpdatedAt = Number.POSITIVE_INFINITY;
|
|
2511
|
+
for (const [sessionId, session] of this.sessions.entries()) {
|
|
2512
|
+
const updatedAt = session.updatedAt.getTime();
|
|
2513
|
+
if (updatedAt < oldestUpdatedAt) {
|
|
2514
|
+
oldestUpdatedAt = updatedAt;
|
|
2515
|
+
oldestSessionId = sessionId;
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
if (oldestSessionId) {
|
|
2519
|
+
this.sessions.delete(oldestSessionId);
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
trimArray(items, maxItems) {
|
|
2523
|
+
if (items.length <= maxItems) {
|
|
2524
|
+
return;
|
|
2525
|
+
}
|
|
2526
|
+
const overflow = items.length - maxItems;
|
|
2527
|
+
items.splice(0, overflow);
|
|
2528
|
+
}
|
|
2494
2529
|
}
|
|
2495
|
-
function createInMemorySessionStore() {
|
|
2496
|
-
return new InMemorySessionStore;
|
|
2530
|
+
function createInMemorySessionStore(options) {
|
|
2531
|
+
return new InMemorySessionStore(options);
|
|
2497
2532
|
}
|
|
2498
2533
|
function generateSessionId() {
|
|
2499
2534
|
return `sess_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
|
@@ -3988,7 +4023,6 @@ var init_opencode_sdk = __esm(() => {
|
|
|
3988
4023
|
|
|
3989
4024
|
// src/agent/unified-agent.ts
|
|
3990
4025
|
init_i18n();
|
|
3991
|
-
import { createProvider } from "@contractspec/lib.ai-providers/factory";
|
|
3992
4026
|
|
|
3993
4027
|
class UnifiedAgent {
|
|
3994
4028
|
spec;
|
|
@@ -4154,6 +4188,7 @@ class UnifiedAgent {
|
|
|
4154
4188
|
if (backendConfig?.modelInstance) {
|
|
4155
4189
|
model = backendConfig.modelInstance;
|
|
4156
4190
|
} else if (backendConfig?.provider) {
|
|
4191
|
+
const { createProvider } = await import("@contractspec/lib.ai-providers/factory");
|
|
4157
4192
|
model = createProvider(backendConfig.provider).getModel();
|
|
4158
4193
|
} else {
|
|
4159
4194
|
const { anthropic } = await import("@ai-sdk/anthropic");
|
package/dist/approval/index.d.ts
CHANGED