@agentuity/cli 0.1.36 → 0.1.38
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/bin/cli.ts +20 -0
- package/dist/agent-detection.d.ts +71 -0
- package/dist/agent-detection.d.ts.map +1 -0
- package/dist/agent-detection.js +232 -0
- package/dist/agent-detection.js.map +1 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +1 -0
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/project-cache.d.ts +16 -0
- package/dist/cache/project-cache.d.ts.map +1 -0
- package/dist/cache/project-cache.js +36 -0
- package/dist/cache/project-cache.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +10 -2
- package/dist/cli.js.map +1 -1
- package/dist/cmd/auth/index.d.ts.map +1 -1
- package/dist/cmd/auth/index.js +0 -2
- package/dist/cmd/auth/index.js.map +1 -1
- package/dist/cmd/auth/org/enroll.d.ts +2 -0
- package/dist/cmd/auth/org/enroll.d.ts.map +1 -0
- package/dist/cmd/auth/{machine/setup.js → org/enroll.js} +14 -14
- package/dist/cmd/auth/org/enroll.js.map +1 -0
- package/dist/cmd/auth/org/index.d.ts.map +1 -1
- package/dist/cmd/auth/org/index.js +53 -10
- package/dist/cmd/auth/org/index.js.map +1 -1
- package/dist/cmd/auth/org/status.d.ts +2 -0
- package/dist/cmd/auth/org/status.d.ts.map +1 -0
- package/dist/cmd/auth/org/status.js +60 -0
- package/dist/cmd/auth/org/status.js.map +1 -0
- package/dist/cmd/auth/org/unenroll.d.ts +2 -0
- package/dist/cmd/auth/org/unenroll.d.ts.map +1 -0
- package/dist/cmd/auth/org/unenroll.js +68 -0
- package/dist/cmd/auth/org/unenroll.js.map +1 -0
- package/dist/cmd/build/ast.d.ts.map +1 -1
- package/dist/cmd/build/ast.js +6 -0
- package/dist/cmd/build/ast.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +11 -4
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/get.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/get.js +6 -1
- package/dist/cmd/cloud/keyvalue/get.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/repl.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/repl.js +6 -1
- package/dist/cmd/cloud/keyvalue/repl.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/set.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/set.js +7 -1
- package/dist/cmd/cloud/keyvalue/set.js.map +1 -1
- package/dist/cmd/cloud/vector/get.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/get.js +5 -0
- package/dist/cmd/cloud/vector/get.js.map +1 -1
- package/dist/cmd/cloud/vector/search.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/search.js +2 -0
- package/dist/cmd/cloud/vector/search.js.map +1 -1
- package/dist/cmd/cloud/vector/upsert.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/upsert.js +24 -1
- package/dist/cmd/cloud/vector/upsert.js.map +1 -1
- package/dist/cmd/project/reconcile.d.ts.map +1 -1
- package/dist/cmd/project/reconcile.js +15 -2
- package/dist/cmd/project/reconcile.js.map +1 -1
- package/dist/cmd/support/report.d.ts.map +1 -1
- package/dist/cmd/support/report.js.map +1 -1
- package/dist/cmd/support/system.d.ts.map +1 -1
- package/dist/cmd/support/system.js +5 -0
- package/dist/cmd/support/system.js.map +1 -1
- package/dist/internal-logger.d.ts +4 -0
- package/dist/internal-logger.d.ts.map +1 -1
- package/dist/internal-logger.js +18 -0
- package/dist/internal-logger.js.map +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +6 -6
- package/src/agent-detection.ts +262 -0
- package/src/cache/index.ts +2 -0
- package/src/cache/project-cache.ts +41 -0
- package/src/cli.ts +10 -2
- package/src/cmd/auth/index.ts +0 -2
- package/src/cmd/auth/{machine/setup.ts → org/enroll.ts} +13 -13
- package/src/cmd/auth/org/index.ts +54 -10
- package/src/cmd/auth/org/status.ts +64 -0
- package/src/cmd/auth/org/unenroll.ts +80 -0
- package/src/cmd/build/ast.ts +6 -0
- package/src/cmd/cloud/deploy.ts +11 -4
- package/src/cmd/cloud/keyvalue/get.ts +6 -1
- package/src/cmd/cloud/keyvalue/repl.ts +6 -1
- package/src/cmd/cloud/keyvalue/set.ts +7 -1
- package/src/cmd/cloud/vector/get.ts +6 -0
- package/src/cmd/cloud/vector/search.ts +2 -0
- package/src/cmd/cloud/vector/upsert.ts +28 -1
- package/src/cmd/project/reconcile.ts +15 -2
- package/src/cmd/support/report.ts +1 -3
- package/src/cmd/support/system.ts +6 -0
- package/src/internal-logger.ts +18 -0
- package/src/types.ts +13 -0
- package/dist/cmd/auth/machine/index.d.ts +0 -2
- package/dist/cmd/auth/machine/index.d.ts.map +0 -1
- package/dist/cmd/auth/machine/index.js +0 -16
- package/dist/cmd/auth/machine/index.js.map +0 -1
- package/dist/cmd/auth/machine/setup.d.ts +0 -2
- package/dist/cmd/auth/machine/setup.d.ts.map +0 -1
- package/dist/cmd/auth/machine/setup.js.map +0 -1
- package/src/cmd/auth/machine/index.ts +0 -16
package/src/cmd/build/ast.ts
CHANGED
|
@@ -141,6 +141,9 @@ export function getDevmodeDeploymentId(projectId: string, endpointId: string): s
|
|
|
141
141
|
return `devmode_${hashSHA1(projectId, endpointId)}`;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
// getAgentId generates the deployment-specific agent ID (becomes database PK agent.id)
|
|
145
|
+
// This ID changes with each deployment and uses the agentid_ prefix
|
|
146
|
+
// Hash includes deploymentId so it's unique per deployment
|
|
144
147
|
function getAgentId(
|
|
145
148
|
projectId: string,
|
|
146
149
|
deploymentId: string,
|
|
@@ -172,6 +175,9 @@ function generateRouteId(
|
|
|
172
175
|
return `route_${hashSHA1(projectId, deploymentId, type, method, filename, path, version)}`;
|
|
173
176
|
}
|
|
174
177
|
|
|
178
|
+
// generateStableAgentId generates the stable identifier (becomes database agent.identifier)
|
|
179
|
+
// This uses the agent_ prefix and is the same across all deployments
|
|
180
|
+
// Hash only includes projectId + name, no deploymentId
|
|
175
181
|
function generateStableAgentId(projectId: string, name: string): string {
|
|
176
182
|
return `agent_${hashSHA1(projectId, name)}`.substring(0, 64);
|
|
177
183
|
}
|
package/src/cmd/cloud/deploy.ts
CHANGED
|
@@ -61,6 +61,7 @@ import { BuildReportCollector, setGlobalCollector, clearGlobalCollector } from '
|
|
|
61
61
|
import { runForkedDeploy } from './deploy-fork';
|
|
62
62
|
import { validateAptDependencies } from '../../utils/apt-validator';
|
|
63
63
|
import { extractDependencies } from '../../utils/deps';
|
|
64
|
+
import { getCachedProject, setCachedProject } from '../../cache';
|
|
64
65
|
|
|
65
66
|
const DeploymentCancelledError = StructuredError(
|
|
66
67
|
'DeploymentCancelled',
|
|
@@ -168,10 +169,16 @@ export const deploySubcommand = createSubcommand({
|
|
|
168
169
|
const hasTTY = process.stdin.isTTY && process.stdout.isTTY;
|
|
169
170
|
if (project.region) {
|
|
170
171
|
try {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
// Check cache first to avoid duplicate API calls
|
|
173
|
+
const profile = config?.name ?? 'default';
|
|
174
|
+
let serverProject = getCachedProject(profile, project.projectId);
|
|
175
|
+
if (!serverProject) {
|
|
176
|
+
serverProject = await projectGet(apiClient, {
|
|
177
|
+
id: project.projectId,
|
|
178
|
+
keys: false,
|
|
179
|
+
});
|
|
180
|
+
setCachedProject(profile, project.projectId, serverProject);
|
|
181
|
+
}
|
|
175
182
|
const serverRegion = serverProject.cloudRegion;
|
|
176
183
|
|
|
177
184
|
if (serverRegion && serverRegion !== project.region) {
|
|
@@ -8,6 +8,7 @@ const KVGetResponseSchema = z.object({
|
|
|
8
8
|
exists: z.boolean().describe('Whether the key exists'),
|
|
9
9
|
data: z.union([z.string(), z.any()]).optional().describe('Value data (string or binary)'),
|
|
10
10
|
contentType: z.string().optional().describe('Content type'),
|
|
11
|
+
expiresAt: z.string().optional().describe('Expiration time as ISO 8601 timestamp'),
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
export const getSubcommand = createCommand({
|
|
@@ -49,8 +50,11 @@ export const getSubcommand = createCommand({
|
|
|
49
50
|
const b = res.data as ArrayBuffer;
|
|
50
51
|
tui.info(`Read ${b.byteLength} bytes (${res.contentType})`);
|
|
51
52
|
}
|
|
53
|
+
const expiresInfo = res.expiresAt
|
|
54
|
+
? `, expires ${new Date(res.expiresAt).toLocaleString()}`
|
|
55
|
+
: '';
|
|
52
56
|
tui.success(
|
|
53
|
-
`retrieved in ${(Date.now() - started).toFixed(1)}ms (${res.contentType})`
|
|
57
|
+
`retrieved in ${(Date.now() - started).toFixed(1)}ms (${res.contentType}${expiresInfo})`
|
|
54
58
|
);
|
|
55
59
|
} else {
|
|
56
60
|
tui.warning(`${args.key} returned empty data for ${args.namespace}`);
|
|
@@ -64,6 +68,7 @@ export const getSubcommand = createCommand({
|
|
|
64
68
|
exists: res.exists,
|
|
65
69
|
data: res.data,
|
|
66
70
|
contentType: res.exists ? res.contentType : undefined,
|
|
71
|
+
expiresAt: res.exists ? res.expiresAt : undefined,
|
|
67
72
|
};
|
|
68
73
|
},
|
|
69
74
|
});
|
|
@@ -37,7 +37,12 @@ export const replSubcommand = createCommand({
|
|
|
37
37
|
z.string().min(1),
|
|
38
38
|
z.string().min(1),
|
|
39
39
|
z.string().min(1),
|
|
40
|
-
z.coerce
|
|
40
|
+
z.coerce
|
|
41
|
+
.number()
|
|
42
|
+
.refine((val) => val >= 0, {
|
|
43
|
+
message: 'TTL must be a non-negative number of seconds',
|
|
44
|
+
})
|
|
45
|
+
.optional(),
|
|
41
46
|
]),
|
|
42
47
|
argNames: ['namespace', 'key', 'value', 'ttl'],
|
|
43
48
|
},
|
|
@@ -42,7 +42,13 @@ export const setSubcommand = createCommand({
|
|
|
42
42
|
namespace: z.string().min(1).max(64).describe('the namespace name'),
|
|
43
43
|
key: z.string().min(1).max(64).describe('the key name'),
|
|
44
44
|
value: z.string().min(1).describe('the value'),
|
|
45
|
-
ttl: z.coerce
|
|
45
|
+
ttl: z.coerce
|
|
46
|
+
.number()
|
|
47
|
+
.refine((val) => val >= 0, {
|
|
48
|
+
message: 'TTL must be a non-negative number of seconds',
|
|
49
|
+
})
|
|
50
|
+
.optional()
|
|
51
|
+
.describe('TTL in seconds (0 for no expiration, values 1-59 clamped to 60 by server)'),
|
|
46
52
|
}),
|
|
47
53
|
response: KVSetResponseSchema,
|
|
48
54
|
},
|
|
@@ -10,6 +10,7 @@ const VectorGetResponseSchema = z.object({
|
|
|
10
10
|
metadata: z.record(z.string(), z.unknown()).optional().describe('Vector metadata'),
|
|
11
11
|
document: z.string().optional().describe('Original document text'),
|
|
12
12
|
similarity: z.number().optional().describe('Similarity score'),
|
|
13
|
+
expiresAt: z.string().optional().describe('Expiration time as ISO 8601 timestamp'),
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
export const getSubcommand = createCommand({
|
|
@@ -79,6 +80,10 @@ export const getSubcommand = createCommand({
|
|
|
79
80
|
if (data.embeddings) {
|
|
80
81
|
tui.info(` Embeddings: [${data.embeddings.length} dimensions]`);
|
|
81
82
|
}
|
|
83
|
+
|
|
84
|
+
if (data.expiresAt) {
|
|
85
|
+
tui.info(` Expires: ${new Date(data.expiresAt).toLocaleString()}`);
|
|
86
|
+
}
|
|
82
87
|
} else {
|
|
83
88
|
tui.warning(`Vector "${tui.bold(args.key)}" not found in ${tui.bold(args.namespace)}`);
|
|
84
89
|
}
|
|
@@ -92,6 +97,7 @@ export const getSubcommand = createCommand({
|
|
|
92
97
|
metadata: result.data.metadata,
|
|
93
98
|
document: result.data.document,
|
|
94
99
|
similarity: result.data.similarity,
|
|
100
|
+
expiresAt: result.data.expiresAt,
|
|
95
101
|
};
|
|
96
102
|
}
|
|
97
103
|
|
|
@@ -8,6 +8,7 @@ const VectorSearchResultSchema = z.object({
|
|
|
8
8
|
key: z.string().describe('Vector key'),
|
|
9
9
|
similarity: z.number().describe('Similarity score (0-1)'),
|
|
10
10
|
metadata: z.record(z.string(), z.unknown()).optional().describe('Vector metadata'),
|
|
11
|
+
expiresAt: z.string().optional().describe('Expiration time as ISO 8601 timestamp'),
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
const VectorSearchResponseSchema = z.object({
|
|
@@ -163,6 +164,7 @@ export const searchSubcommand = createCommand({
|
|
|
163
164
|
key: r.key,
|
|
164
165
|
similarity: r.similarity,
|
|
165
166
|
metadata: r.metadata,
|
|
167
|
+
expiresAt: r.expiresAt,
|
|
166
168
|
})),
|
|
167
169
|
count: results.length,
|
|
168
170
|
};
|
|
@@ -18,6 +18,7 @@ const VectorUpsertResponseSchema = z.object({
|
|
|
18
18
|
)
|
|
19
19
|
.describe('Upsert results with key-to-id mappings'),
|
|
20
20
|
durationMs: z.number().describe('Operation duration in milliseconds'),
|
|
21
|
+
ttl: z.number().optional().describe('TTL in seconds if set'),
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
export const upsertSubcommand = createCommand({
|
|
@@ -43,6 +44,12 @@ export const upsertSubcommand = createCommand({
|
|
|
43
44
|
command: getCommand('vector upsert embeddings vec1 --embeddings "[0.1, 0.2, 0.3]"'),
|
|
44
45
|
description: 'Upsert with pre-computed embeddings',
|
|
45
46
|
},
|
|
47
|
+
{
|
|
48
|
+
command: getCommand(
|
|
49
|
+
'vector upsert products doc1 --document "Limited time offer" --ttl 86400'
|
|
50
|
+
),
|
|
51
|
+
description: 'Upsert with 24h TTL',
|
|
52
|
+
},
|
|
46
53
|
{
|
|
47
54
|
command: getCommand('vector upsert products --file vectors.json'),
|
|
48
55
|
description: 'Bulk upsert from JSON file',
|
|
@@ -68,6 +75,13 @@ export const upsertSubcommand = createCommand({
|
|
|
68
75
|
.string()
|
|
69
76
|
.optional()
|
|
70
77
|
.describe('path to JSON file containing vectors, or "-" for stdin'),
|
|
78
|
+
ttl: z.coerce
|
|
79
|
+
.number()
|
|
80
|
+
.refine((val) => val >= 0, {
|
|
81
|
+
message: 'TTL must be a non-negative number of seconds',
|
|
82
|
+
})
|
|
83
|
+
.optional()
|
|
84
|
+
.describe('TTL in seconds (0 for no expiration, values 1-59 clamped to 60 by server)'),
|
|
71
85
|
}),
|
|
72
86
|
response: VectorUpsertResponseSchema,
|
|
73
87
|
},
|
|
@@ -118,7 +132,10 @@ export const upsertSubcommand = createCommand({
|
|
|
118
132
|
tui.fatal('Invalid JSON in input file/stdin');
|
|
119
133
|
}
|
|
120
134
|
|
|
121
|
-
// Validate documents
|
|
135
|
+
// Validate documents and apply TTL from command line if not set in document
|
|
136
|
+
// Handle TTL: 0 means no expiration (null in API), undefined means use default
|
|
137
|
+
const cliTtl = opts.ttl === 0 ? null : opts.ttl;
|
|
138
|
+
|
|
122
139
|
for (const doc of documents) {
|
|
123
140
|
if (!doc.key || typeof doc.key !== 'string') {
|
|
124
141
|
tui.fatal('Each document must have a non-empty "key" property');
|
|
@@ -128,6 +145,10 @@ export const upsertSubcommand = createCommand({
|
|
|
128
145
|
`Document with key "${doc.key}" must have either "document" or "embeddings" property`
|
|
129
146
|
);
|
|
130
147
|
}
|
|
148
|
+
// Apply CLI TTL to documents that don't have their own TTL set
|
|
149
|
+
if (cliTtl !== undefined && doc.ttl === undefined) {
|
|
150
|
+
doc.ttl = cliTtl;
|
|
151
|
+
}
|
|
131
152
|
}
|
|
132
153
|
} else {
|
|
133
154
|
// Single vector upsert via command line arguments
|
|
@@ -152,12 +173,16 @@ export const upsertSubcommand = createCommand({
|
|
|
152
173
|
}
|
|
153
174
|
}
|
|
154
175
|
|
|
176
|
+
// Handle TTL: 0 means no expiration (null in API), undefined means use default
|
|
177
|
+
const ttl = opts.ttl === 0 ? null : opts.ttl;
|
|
178
|
+
|
|
155
179
|
if (opts.document) {
|
|
156
180
|
documents = [
|
|
157
181
|
{
|
|
158
182
|
key: args.key,
|
|
159
183
|
document: opts.document,
|
|
160
184
|
metadata,
|
|
185
|
+
ttl,
|
|
161
186
|
},
|
|
162
187
|
];
|
|
163
188
|
} else if (opts.embeddings) {
|
|
@@ -176,6 +201,7 @@ export const upsertSubcommand = createCommand({
|
|
|
176
201
|
key: args.key,
|
|
177
202
|
embeddings,
|
|
178
203
|
metadata,
|
|
204
|
+
ttl,
|
|
179
205
|
},
|
|
180
206
|
];
|
|
181
207
|
}
|
|
@@ -210,6 +236,7 @@ export const upsertSubcommand = createCommand({
|
|
|
210
236
|
count: results.length,
|
|
211
237
|
results,
|
|
212
238
|
durationMs,
|
|
239
|
+
ttl: opts.ttl,
|
|
213
240
|
};
|
|
214
241
|
},
|
|
215
242
|
});
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
splitEnvAndSecrets,
|
|
24
24
|
} from '../../env-util';
|
|
25
25
|
import { fetchRegionsWithCache } from '../../regions';
|
|
26
|
+
import { getCachedProject, setCachedProject } from '../../cache';
|
|
26
27
|
|
|
27
28
|
export interface ReconcileResult {
|
|
28
29
|
status: 'valid' | 'imported' | 'skipped' | 'error';
|
|
@@ -468,7 +469,13 @@ export async function reconcileProject(opts: ReconcileOptions): Promise<Reconcil
|
|
|
468
469
|
if (projectConfig) {
|
|
469
470
|
// 2. Validate access to existing project
|
|
470
471
|
try {
|
|
471
|
-
|
|
472
|
+
// Check cache first to avoid duplicate API calls
|
|
473
|
+
const profile = config?.name ?? 'default';
|
|
474
|
+
let project = getCachedProject(profile, projectConfig.projectId);
|
|
475
|
+
if (!project) {
|
|
476
|
+
project = await projectGet(apiClient, { id: projectConfig.projectId, keys: false });
|
|
477
|
+
setCachedProject(profile, projectConfig.projectId, project);
|
|
478
|
+
}
|
|
472
479
|
|
|
473
480
|
// 3. Check if orgId matches user's orgs
|
|
474
481
|
const userOrgs = await listOrganizations(apiClient);
|
|
@@ -542,7 +549,13 @@ export async function runProjectImport(opts: ReconcileOptions): Promise<Reconcil
|
|
|
542
549
|
|
|
543
550
|
if (projectConfig) {
|
|
544
551
|
try {
|
|
545
|
-
|
|
552
|
+
// Check cache first to avoid duplicate API calls
|
|
553
|
+
const profile = config?.name ?? 'default';
|
|
554
|
+
let project = getCachedProject(profile, projectConfig.projectId);
|
|
555
|
+
if (!project) {
|
|
556
|
+
project = await projectGet(apiClient, { id: projectConfig.projectId, keys: false });
|
|
557
|
+
setCachedProject(profile, projectConfig.projectId, project);
|
|
558
|
+
}
|
|
546
559
|
const userOrgs = await listOrganizations(apiClient);
|
|
547
560
|
const hasAccess = userOrgs.some((org) => org.id === project.orgId);
|
|
548
561
|
|
|
@@ -257,9 +257,7 @@ export default createSubcommand({
|
|
|
257
257
|
if (isJsonMode) {
|
|
258
258
|
console.log(JSON.stringify({ success: false, error: 'Description is required' }));
|
|
259
259
|
} else {
|
|
260
|
-
tui.error(
|
|
261
|
-
'Description is required. Use --description flag or pipe input via stdin.'
|
|
262
|
-
);
|
|
260
|
+
tui.error('Description is required. Use --description flag or pipe input via stdin.');
|
|
263
261
|
}
|
|
264
262
|
return;
|
|
265
263
|
}
|
|
@@ -7,6 +7,7 @@ import { getLatestLogSession } from '../../internal-logger';
|
|
|
7
7
|
import * as tui from '../../tui';
|
|
8
8
|
import { getVersion, getPackageName } from '../../version';
|
|
9
9
|
import { getAuth } from '../../config';
|
|
10
|
+
import { isExecutingFromAgent } from '../../agent-detection';
|
|
10
11
|
|
|
11
12
|
const argsSchema = z.object({});
|
|
12
13
|
|
|
@@ -75,6 +76,9 @@ export default createSubcommand({
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
// Get detected agent (if any)
|
|
80
|
+
const detectedAgent = await isExecutingFromAgent();
|
|
81
|
+
|
|
78
82
|
// Gather system information
|
|
79
83
|
const systemInfo = {
|
|
80
84
|
cli: {
|
|
@@ -100,6 +104,7 @@ export default createSubcommand({
|
|
|
100
104
|
user: {
|
|
101
105
|
userId: userId,
|
|
102
106
|
},
|
|
107
|
+
agent: detectedAgent || null,
|
|
103
108
|
};
|
|
104
109
|
|
|
105
110
|
if (isJsonMode) {
|
|
@@ -122,6 +127,7 @@ export default createSubcommand({
|
|
|
122
127
|
{ Property: 'Home Directory', Value: systemInfo.paths.home },
|
|
123
128
|
{ Property: 'Config Directory', Value: systemInfo.paths.configDir },
|
|
124
129
|
{ Property: 'User ID', Value: systemInfo.user.userId },
|
|
130
|
+
{ Property: 'Detected Agent', Value: systemInfo.agent || 'none' },
|
|
125
131
|
];
|
|
126
132
|
|
|
127
133
|
tui.table(tableData, ['Property', 'Value'], { layout: 'vertical' });
|
package/src/internal-logger.ts
CHANGED
|
@@ -388,6 +388,24 @@ export class InternalLogger implements Logger {
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
+
/**
|
|
392
|
+
* Update the session with detected agent name
|
|
393
|
+
*/
|
|
394
|
+
setDetectedAgent(agent: string): void {
|
|
395
|
+
if (!this.initialized || this.disabled) return;
|
|
396
|
+
|
|
397
|
+
try {
|
|
398
|
+
// Read existing session data
|
|
399
|
+
const existingData = JSON.parse(readFileSync(this.sessionFile, 'utf-8'));
|
|
400
|
+
existingData.detectedAgent = agent;
|
|
401
|
+
// Write updated session data
|
|
402
|
+
writeFileSync(this.sessionFile, JSON.stringify(existingData, null, 2));
|
|
403
|
+
} catch (err) {
|
|
404
|
+
// Ignore errors - this is a best-effort update
|
|
405
|
+
console.debug(`Failed to update detectedAgent in session: ${err}`);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
391
409
|
/**
|
|
392
410
|
* Disable the internal logger (prevents init and logging)
|
|
393
411
|
*/
|
package/src/types.ts
CHANGED
|
@@ -422,6 +422,19 @@ export type CommandContextFromSpecs<
|
|
|
422
422
|
config: Config | null;
|
|
423
423
|
logger: Logger;
|
|
424
424
|
options: GlobalOptions;
|
|
425
|
+
/**
|
|
426
|
+
* Check if the CLI is being executed from a known coding agent.
|
|
427
|
+
* Returns the agent name if detected, undefined otherwise.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* const agent = await ctx.isExecutingFromAgent();
|
|
432
|
+
* if (agent) {
|
|
433
|
+
* logger.debug(`Running from agent: ${agent}`);
|
|
434
|
+
* }
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
isExecutingFromAgent: () => Promise<string | undefined>;
|
|
425
438
|
} & AddArgs<A> &
|
|
426
439
|
AddOpts<Op> &
|
|
427
440
|
AddAuth<AuthMode<R, O>> &
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cmd/auth/machine/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,sCAW5B,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createCommand } from '../../../types';
|
|
2
|
-
import { setupSubcommand } from './setup';
|
|
3
|
-
import { getCommand } from '../../../command-prefix';
|
|
4
|
-
export const machineSubcommand = createCommand({
|
|
5
|
-
name: 'machine',
|
|
6
|
-
description: 'Manage machine authentication for self-hosted infrastructure',
|
|
7
|
-
tags: ['fast', 'requires-auth'],
|
|
8
|
-
examples: [
|
|
9
|
-
{
|
|
10
|
-
command: getCommand('auth machine setup --file ./public-key.pem'),
|
|
11
|
-
description: 'Set up machine authentication with a public key',
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
subcommands: [setupSubcommand],
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cmd/auth/machine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;IAC9C,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,8DAA8D;IAC3E,IAAI,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC;IAC/B,QAAQ,EAAE;QACT;YACC,OAAO,EAAE,UAAU,CAAC,4CAA4C,CAAC;YACjE,WAAW,EAAE,iDAAiD;SAC9D;KACD;IACD,WAAW,EAAE,CAAC,eAAe,CAAC;CAC9B,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../../src/cmd/auth/machine/setup.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,eAAe,yCA0F1B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../../src/cmd/auth/machine/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;IAC5D,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;CACjD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAC;IAC/C,IAAI,EAAE,OAAO;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BAClF,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,GAAG,CAAC,IAAI,CACP,qFAAqF,CACrF,CAAC;YACH,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;QAC/C,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACb,GAAG,CAAC,KAAK,CAAC,4CAA4C,EAAE,EAAE,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAClF,CAAC;IACF,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createCommand } from '../../../types';
|
|
2
|
-
import { setupSubcommand } from './setup';
|
|
3
|
-
import { getCommand } from '../../../command-prefix';
|
|
4
|
-
|
|
5
|
-
export const machineSubcommand = createCommand({
|
|
6
|
-
name: 'machine',
|
|
7
|
-
description: 'Manage machine authentication for self-hosted infrastructure',
|
|
8
|
-
tags: ['fast', 'requires-auth'],
|
|
9
|
-
examples: [
|
|
10
|
-
{
|
|
11
|
-
command: getCommand('auth machine setup --file ./public-key.pem'),
|
|
12
|
-
description: 'Set up machine authentication with a public key',
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
subcommands: [setupSubcommand],
|
|
16
|
-
});
|